提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
计算int值的平方根
public class Root {// from nowjava.com - 时 代 Java public static void main(String[] args) { int i = 2; double r = Math.sqrt(i); System.out.print("The square root of "); System.out.print(i); System.out.print(" is "); System.out.print(r); System.out.println("."); i = 5; r = Math.sqrt(i); System.out.println("The square root of " + i + " is " + r + "."); } }