in my code i have Numbers from 0 to 10 , i am use random methods ,
so i want calculate the sum of them , how can i done by use mehods ?
note : i will use it in GUI ( JFrame )
public static int random1 ()
{
Random n = new Random () ;
int x = n.nextInt( 10 ) + 0 ;
return x ;
}
public static int random2 ()
{
Random n = new Random () ;
int y = n.nextInt( 10 ) + 0 ;
return y;
}
public void sum ()
{
int result = x.random1() + y.random2() ;
}
You just need one random method, and use it: result = random()+random()
int result = random1() + random2();
although both of your methods do exactly the same thing, so get rid of the second method, rename the first method random and then
int result = random() + random();