Switch to Bing in English
リンクを新しいタブで開く
  1. 元に戻す
    やり直し
    コピー
    エクスポート
    書き換え
    長さを変更する
    トーンを変更する
    • 作業報告
    • メール
    • リライト
    • スピーチ
    • タイトル ジェネレーター
    • スマート返信
    • エッセイ
    • ジョーク
    • Instagram 投稿
    • X 投稿
    • Facebook 投稿
    • ストーリー
    • 添え状
    • 履歴書
    • 職務明細書
    • 推薦状
    • 退職願
    • 招待状
    • グリーティング メッセージ
    • その他のテンプレートを試します
  1. To calculate the square root of a number in Java, you can use the Math.sqrt() method from the java.lang.Math package. This method returns the square root of a given number as a double.

    Example: Using Math.sqrt()

    public class SquareRootExample {
    public static void main(String[] args) {
    double number = 64;
    double result = Math.sqrt(number);
    System.out.println("Square root of " + number + " is: " + result);
    }
    }
    コピーしました。

    Output:

    Square root of 64 is: 8.0
    コピーしました。

    Alternative: Using Math.pow()

    You can also calculate the square root using the formula number^(1/2) with the Math.pow() method.

    public class SquareRootWithPow {
    public static void main(String[] args) {
    double number = 81;
    double result = Math.pow(number, 0.5);
    System.out.println("Square root of " + number + " is: " + result);
    }
    }
    コピーしました。

    Without Built-in Methods

    If you want to avoid built-in methods, you can use an iterative approach like the Newton-Raphson method.

    フィードバック
    ありがとうございました!詳細をお聞かせください
  2. 【Java】sqrtメソッドで平方根(ルート√)を求める方法

    2023年2月11日 · Java の Mathクラス の sqrtメソッド で 平方根 を求める方法を紹介します。 また、 sqrtメソッド を使わずに平方根を計算する方法も紹介します。 ここで、平方根とは数 a a があると …

  3. Java Math sqrt () Method - GeeksforGeeks

    2025年5月13日 · This method returns the square root of a given value of type double. In this article, we are going to discuss how this method works for regular values and for special cases such as infinity …

  4. Java Sqrt (): Program to Find Square and Square Root in Java

    2024年7月5日 · One of the most popular frequently asked Java Interview Question is, “ Given an integer x, write a java program to find the square root of it”. There are many ways to solve this problem. In this …

  5. How to Find the Square Root of a Number in Java

    2024年3月19日 · In this section, we will explain how to compute the square root of a number in Java using the binary search algorithm. We split the code into three chunks: two user-defined functions and …

  6. Java Program to Find Square Root of a Number (6 Ways)

    2025年11月17日 · Learn how to find the square root of a number in Java using 6 simple methods. Includes Math.sqrt (), Power Function, and more. Read now!

  7. 他の人も質問しています
  8. Java Math sqrt () - Programiz

    In this tutorial, we will learn about Math.sqrt () method with the help of an example.

  9. Square Root in Java - CodeGym

    2025年2月18日 · The most common way to find a square root of a number in Java is by applying the java.lang.Math.sqrt() method. Here’s the general syntax of the java.lang.Math.sqrt () method: In the …

  10. Square Root in Java | Math.sqrt () and Custom Methods - upGrad

    3 日前 · Learn how to find square root in Java using Math.sqrt () and custom logic. Includes code examples, best practices, time complexity, and method variations.

  11. Java How To: Calculate Square Root - CodeLucky

    2024年8月31日 · Learn how to calculate the square root in Java with our step-by-step guide. Understand the methods and coding examples to enhance your programming skills effectively.

  12. Java sqrt () Method: Complete Guide with Practical Examples

    2025年5月21日 · In this comprehensive guide, I‘ll walk you through everything you need to know about the Math.sqrt() method, from basic usage to advanced applications. The sqrt() method in Java is part …

このサイトを利用すると、分析、カスタマイズされたコンテンツ、広告に Cookie を使用することに同意したことになります。サード パーティの Cookie に関する詳細情報|Microsoft のプライバシー ポリシー