wap in Java to accept 3 numbers and display the minimum number among then
siddhartharao77:
Can i use collections in this?
Answers
Answered by
1
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Hello
{
public static void main(String args[])
{
Integer[] Demo = new Integer[5];
System.out.println("Enter the numbers");
Scanner scan = new Scanner(System.in);
for( int i = 0;i <Demo.length;i++)
{
System.out.println("Number["+i+"]:");
Demo[i] = scan.nextInt();
}
int small = (int) Collections.min(Arrays.asList(Demo));
System.out.println("Minimum number is: " + small);
}
}
Hope this helps!
import java.util.Collections;
import java.util.Scanner;
public class Hello
{
public static void main(String args[])
{
Integer[] Demo = new Integer[5];
System.out.println("Enter the numbers");
Scanner scan = new Scanner(System.in);
for( int i = 0;i <Demo.length;i++)
{
System.out.println("Number["+i+"]:");
Demo[i] = scan.nextInt();
}
int small = (int) Collections.min(Arrays.asList(Demo));
System.out.println("Minimum number is: " + small);
}
}
Hope this helps!
Similar questions