Two while loop with getter and setter method
I want to set a random number and print continuously. `fig` class is for set values and `sestk` class is for get values. I used while loop on both `fig` class and `sestk` class . My codes fig.java import java.util.Random; public class fig { public static void main(String[] args) { gsc fi = new gsc(); Random random = new Random(); while(true) { int a = random.nextInt(50); int b= random.nextInt(50); System.out.println("("+a+" , "+b+")"); fi.setdb( a,b); sestk dp = new sestk(); dp.a(); } } } gsc.java public class gsc { private static int a; private static int b; public void setdb(int c, int d){ this.a = c; this.b = d; } public int getdba(){ return a; } public int getdbb(){ return b; } } sestk.java public class mousestk { gsc a= new gsc(); public void a() { while (true){ System.out.println(a.getdba()+" x , y "+a.getdbb()); } } } OUTPUT (26 , 44) 26 x , y 44 26 x , y 44 26 x , y 44 26 x , y 44 26 x , y 44 The output printing ` 26 x , y 44` continuously . only one time the random value was generated and set in `gsc` class. I want to set random value contineously and get different outputs. `fig` class is for set values and `sestk` class is for get values. I used while loop on both `fig` class and `sestk` class . but , only one time `fig` class prints the random number. `sestk` class prints the get value from `gsc` class continuously . How Can I do this ? Is there any other methods to do this ? I asked this question , because I want to apply this concept in my graph project.