本文介绍了语法错误? “找不到符号”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

一个初学者问题:

请求帮助我( - :


错误(箭头指向)在sqrt中的s)

=====

tal.java:6:找不到符号

符号:方法sqrt(int )

位置:class tal

System.out.println(i +":" + sqrt(4));

^

1错误

来源

=====

class tal {

public static void main(String [] arguments){

for(int i = 0; i< 11; i ++){

System.out.println(i + ":" + sqrt(4));

}

}

}


/ Bjorn

Hi!
An beginner question:
Pleas help me with this (-:

Error (the arrow points on the s in sqrt)
=====
tal.java:6: cannot find symbol
symbol : method sqrt(int)
location: class tal
System.out.println(i + ": " + sqrt(4));
^
1 error
Source
=====
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
}

/Bjorn

推荐答案



你是sqrt函数吗甚至做过?如果没有,那么你应该做到。如果你有

的函数sqrt,你可能已经把它设为静态,因为你想从main函数里面引用
引用。不幸的是Java不允许

那个。

Is you sqrt function even made? If not then you should make it. If you have
made the function sqrt, you probably have made it static since you want to
reference from inside the main function. Unfortunately Java doesnt allow
that.





试试这个:


class tal

{

public static void main(String [] arguments)

{

for(int i = 0; i< arguments.length; i ++)

{

System.out.println(i +":" +

java.lang.Math.sqrt(Double.parseDouble(arguments [i])));

}

}

}

在此先感谢...

IchBin,Pocono Lake,Pa,USA

______________________________ ____________________ ________________________


''如果有的话,知识就是青春之泉''

-William E. Taylor,Regular Guy(1952) - )

Try this:

class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " +
java.lang.Math.sqrt(Double.parseDouble(arguments[i])));
}
}
}
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________

''If there is one, Knowledge is the "Fountain of Youth"''
-William E. Taylor, Regular Guy (1952-)


这篇关于语法错误? “找不到符号”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:44