How To Find the Largest and Smallest Value in Java

How To Find the Largest and Smallest Value in Java

Codes:

import java.util.Scanner;
public class maxmin {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int min=Integer.MAX_VALUE;
		int max=Integer.MIN_VALUE;
		
		for (int i=1; i<=10; i++)
		{
			System.out.print(i+"th number is: ");
			int number=input.nextInt();
			
			if (i==1)
			{
				min = number;
				max = number;
			}
			else
			{
				if (number > max)
					max = number;
				
				if (number < min)
					min = number;
			}
		}
		System.out.println("Max number is: "+max);
		System.out.println("Min number is: "+min);
	}

}

Output Screen:

java find min max