Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

433
Views
how can i call value from methods?

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() ;
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You just need one random method, and use it: result = random()+random()

over 4 years ago · Santiago Trujillo Report

0

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();
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!