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

441
Views
¿Cómo puedo llamar al valor de los métodos?

en mi código tengo números del 0 al 10, uso métodos aleatorios,

entonces quiero calcular la suma de ellos, ¿cómo puedo hacerlo usando métodos?

nota: lo usaré en 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

Solo necesita un método random y utilícelo: result = random()+random()

over 4 years ago · Santiago Trujillo Report

0

int result = random1() + random2();

aunque ambos métodos hacen exactamente lo mismo, así que deshazte del segundo método, cambia el nombre del primer método al azar y luego

 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!