I have redrafted the problem so as to be conceptually simpler.
I have two calsses, a main class and resources class.
MAIN CLASS
public class Main { private static Resources resource = new Resources(); public static void main(String[] args) { System.out.println("Program initiating"); resource.add(1); System.out.println(resource.Queue); } }
RESOURCE CLASS
public class Resources { public int Queue; public boolean status; public Resources() { Queue = 0; status = false; } public void add(int x) { System.out.println("y is \t" + "Queue here is "); int y = x + 3; while (y<20) { y++; Queue++; System.out.println(y + "\t" + Queue + "\t"); } //return y; } }
I want to see the Queue variable in the resources class being changed as it loops. However i would like to do this by calling the Queue variable in the Resources class from the main class. Currently, when i do this (through System.out.println(resource.Queue); in the Main class), i am only being returned with the final number in Queue after all the loop has been done.
Is there a way to implement this from the main class?
thanks