What code to find Max value and min value in this Array... ? Help me Please..?

import java.util.Scanner;
import java.lang.Math;
class Work4_1
{
    public static void main(String[] args)
    {
        Scanner input=new Scanner(System.in);
        int[] value=new int[10];
        int max,min;
        for(int i=1;i<value.length;i++)
        {
            System.out.print("Enter Value : ");
            value[i]=input.nextInt();
        }
        Math.max(value[i]); <<< It's True...?
        Math.min(value[i]);  <<< It's True...?
        }
}

Thanks

As you get each number you need to compare it with the current max and min values. If it's less than the current min, it becomes the new min, ditto for max.
You can use Math.max if you like, it needs TWO parameters and returns the larger of the two, but I recommend that you do not use it, just code the if test yourself. That way youi'll learn more, and will be in better shape for tracking which element of the array is largest, if you need to.

Use the following code, after you take the value in your array

TreeSet ts = new TreeSet();

for(int i = 0; i < value.length; i++)
{
ts.add(value);
}

the numbers will be automatically sorted. Pick the first and last number as the max and min numbers required.

Check out
SNIP
for more help on implementing this type of code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.