I have the following code:

import java.util.Scanner;

public class WhileLoop {

    public static void main(String[] args) {

        int number;
        int maxValue = Integer.MAX_VALUE;
        int minValue = Integer.MIN_VALUE;

        Scanner input = new Scanner (System.in);

        System.out.println("Enter the length of numbers");
        int loop = input.nextInt();

        for(int i=1; i<=loop; i++){

            System.out.println("Enter a number: ");
            number = input.nextInt();

        if (number > maxValue) {
            maxValue = number;
            }
        if (number < minValue){
            minValue = number;
            }
            }
        System.out.println("Maximum Value is : " + maxValue);
        System.out.println("Minimum Value is : " + minValue);       
            }   
        }

its showing the result:
Maximum Value is : 2147483647
Minimum Value is : -2147483648

Can any buddy help me out?

What is the problem (or your expectation)?

My guess is you want to initialize maxValue and minValue the other way around.

"the other way around":

 for(int i=1; i<=loop; i++){
System.out.println("Enter a number: ");
number = input.nextInt();

if(i==1){
maxValue = number;
minValue = number;
}
else{
if (number > maxValue) {
maxValue = number;
}
if (number < minValue){
minValue = number;
}}}

Good luck

This question has already been answered. Start a new discussion instead.