You coded the following on lines 10-12 of class Test.java;
String s; // line 10
int I = s.length( ); // line 11
when you compile,
Test.java:11: error: variable s might not have been initialized
int I = s.length( ); // line 11
^
1 error
what is the problem and how to fix
Test.java:10: error: cannot find symbol
double d = Math.PI( ); // line 10
^
symbol : method PI( )
location : class Math
1 error
what is the problem and how to fix
String s; // line 10
int I = s.length( ); // line 11
when you compile,
Test.java:11: error: variable s might not have been initialized
int I = s.length( ); // line 11
^
1 error
what is the problem and how to fix
Ans. Intialize string with empty String to get length.
such that
String s = "";
int l = s.length();
System.out.println(l);
/* OUTPUT */
0
what is the problem and how to fix
Test.java:10: error: cannot find symbol
double d = Math.PI( ); // line 10
Ans.
double d = Math.PI; // PI is static variable not method
MEANS CANNOT USE PI()
System.out.println(d);
/* OUTPUT */
3.141592653589793
/* PLEASE UPVOTE */
Get Answers For Free
Most questions answered within 1 hours.