- Joined
- Mar 20, 2023
- Messages
- 1
- Reaction score
- 0
Hello Everyone I have a problem with the void stuff in java I do not understand exactly what it does I did this code and I put public static void in the Mayor method but java told me that it can not be used there now this code works but I do not understand exactly how the void statemente works, any help will be so useful thank you so much
package pruebas.pruebasbuenas;
import java.util.Scanner;
public class granja {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//atributos//
int n = input.nextInt();
int j = input.nextInt();
//Condición de igualdad//
if(n==j){
System.out.println("ambos números son iguales");
}
else{
System.out.println(Mayor(n,j));
}
}
public static int Mayor(int n,int j){
if(n>j){
return n;
}
else{
return j;
}
}
}
package pruebas.pruebasbuenas;
import java.util.Scanner;
public class granja {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//atributos//
int n = input.nextInt();
int j = input.nextInt();
//Condición de igualdad//
if(n==j){
System.out.println("ambos números son iguales");
}
else{
System.out.println(Mayor(n,j));
}
}
public static int Mayor(int n,int j){
if(n>j){
return n;
}
else{
return j;
}
}
}