public class Example {
public int num, num2;
public Example () {
num = 10;
}
public void method1 () {
num2 = num + 1;
System.out.println(num2);
}
public void method2 () {
num = 20;
}
}
When I call the first method, I get 11 (as I should). However, after calling the second method and then the first again, I expect to get 21. This does not happen. How do I edit this code so that variables can be changed in one method and used in another? Thanks in advance.
This post has been edited by ninjawesome222: 08 February 2012 - 09:09 AM

New Topic/Question
Reply




MultiQuote




|