|
hello all, I can't compile the following code segment:
class StringTest
{
public static void main(String[] args)
{
int v1 = 3;
double v2 = 1.414;
char v3 = 'c';
String s1 = String.valueof(v1);
String s2 = String.valueof(v2);
String s3 = String.valueof(v3);
}
}
|
|
|
The compiler tells the details:
C:\jexp>javac stringtest.java
stringtest.java:8: cannot find symbol
symbol : method valueof(int)
location: class java.lang.String
String s1 = String.valueof(v1);
^
stringtest.java:9: cannot find symbol
symbol : method valueof(double)
location: class java.lang.String
String s2 = String.valueof(v2);
^
stringtest.java:10: cannot find symbol
symbol : method valueof(char)
location: class java.lang.String
String s3 = String.valueof(v3);
^
3 errors
It cannot find the symbol = method "valueof"
Look in the String api for this method and find it is spelled "valueOf"
|
|
|
|
|
|
|
// |