I have a class named collect.java that looks like this:
I also have a main class-
I was expecting the testcollect class to simply print out 5. Yet I get the error message "cannot find variable x". Please help.
Code:
public class collect {
public int returnX() {
int x=5;
return x;
}
}
Code:
public class testcollect {
public static void main(String[] args) {
collect collector = new collect();
collector.returnX();
System.out.println(x);
}
}
Comment