Haz todo lo posible por comprender el código correctamente previamente a usarlo a tu proyecto y si tquieres aportar algo puedes decirlo en los comentarios.
Ejemplo 1: programa Java para encontrar el mayor de tres números
java program find largest of three numbers using command line argument
public class UsingCommandLineArgument
public static void main(String[] args)
int number1 = Integer.parseInt(args[0]);
int number2 = Integer.parseInt(args[1]);
int number3 = Integer.parseInt(args[2]);
if(number1 > number2 && number1 > number3)
System.out.println(number1 + " is largest number.");
else if(number2 > number1 && number2 > number3)
System.out.println(number2 + " is largest number.");
else
System.out.println(number3 + " is largest number.");
Ejemplo 2: cómo encontrar el entero más grande en Java
int a = Integer.MAX_VALUE;
Ejemplo 3: cómo encontrar el número más grande en java
int number1 = 2;
int number2 = 1;
System.out.println("The largest number is " + Math.max(number1, number2));
System.out.println("The smallest number is " + Math.min(number1, number2));
Ejemplo 4: Java encuentra el número más grande en la lista
int max = (The provided List).stream().max((i1,i2)->(i1>i2)?1:(i1
Example 5: Java program to find largest of three numbers
Java program to find largest of four numbers using if-else
import java.util.Scanner;
public class FourNumbersUsingIfElse
public static void main(String[] args)
Scanner sc = new Scanner(System.in);
System.out.println("Please enter first number to find largest: ");
int number1 = sc.nextInt();
System.out.println("Please enter second number to find largest: ");
int number2 = sc.nextInt();
System.out.println("Please enter third number to find largest: ");
int number3 = sc.nextInt();
System.out.println("Please enter fourth number to find largest: ");
int number4 = sc.nextInt();
if(number1 > number2 && number1 > number3 && number1 > number4)
System.out.println(number1 + " is largest.");
else if(number2 > number1 && number2 > number3 && number2 > number4)
System.out.println(number2 + " is largest.");
else if(number3 > number1 && number3 > number2 && number3 > number4)
System.out.println(number3 + " is largest.");
else
System.out.println(number4 + " is largest.");
sc.close();
Puedes añadir valor a nuestra información asistiendo con tu experiencia en las ilustraciones.
¡Haz clic para puntuar esta entrada!
(Votos: 2 Promedio: 3.5)