Computer Science, asked by Rhea13, 1 year ago

wap in Java to accept 3 numbers and display the minimum number among then


siddhartharao77: Can i use collections in this?
siddhartharao77: okk..Then i will write the program directly.

Answers

Answered by siddhartharao77
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!

Rhea13: actually ir didnt help but thnx for the effort
siddhartharao77: :-))
siddhartharao77: My Mistake. Most of them don't know about collections in java.
Similar questions