Variable Error during compiling [message #1815963] |
Wed, 16 October 2019 01:56  |
Eclipse User |
|
|
|
Hi! I'm new to Java using eclipse kepler. I am following a video tutorial and i followed all the syntax correctly but eclipse says "temp temp cannot be resolve to a variable"
My question is: Is it a syntax error or an eclipse version problem?
Glad to have your comments. Thanks.
package Day.examples;
public class ExampleArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
int []x = {10,20,30,40,50};
System.out.println(x[0]+" "+x[3]);
for (int temp : x);
{System.out.println(temp);}
}
}
|
|
|
|
Re: Variable Error during compiling [message #1816003 is a reply to message #1815969] |
Wed, 16 October 2019 22:47  |
Eclipse User |
|
|
|
Hi sir. Thank you very much for your response. I've followed your instruction and I am still having the same error message. I found the problem by accident in the JRE system library that I am using. The default should be C:\Program files\Java\jdk 1.8.0.221 instead of C:\Program files\Java\jre 1.8.0.231. I remember that I installed java jre 1.80.231 and eclipse switch automatically to the new system library. So, when i switch back to the original library which is java JDK, it works fine.
package Day.examples;
public class ExampleArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
int []x = {10,20,30,40,50};
System.out.println(x[0]+" "+x[3]);
for (int temp : x){
System.out.println(temp);
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.08325 seconds