Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

434
Vistas
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 Respuestas
Responde la pregunta

0

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

over 4 years ago · Santiago Trujillo Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda