I am working on simple example.Initially taking the value of a as 1 and b as 2. I am calling method to do an update, when I print this a and b. It will be 1 and 2 as expected. But I should update this a and b in each loop, How can I do this?I am getting thought of returning as list. Is there a simple way to accomplish it?
public class UpdateTest {
public static void main(String[] args) {
int a=1;
int b=2;
for (int i = 0; i < 5; i++) {
update(a,b);
}
System.out.println(a+"------"+b);
}
private static void update(int a, int b) {
// TODO Auto-generated method stub
for (int i = 0; i < 10; i++) {
a++;
b++;
}
}
}