All pastes #32365 Raw Edit

Stuff

public text v1 · immutable
#32365 ·published 2005-12-04 15:25 UTC
rendered paste body
public class GetMax
{
	public static void main(String [] args)
	{
		System.out.println("How many elements do u want");
		int size = Console.readInt();
		int [] nums= new int[size];


		System.out.println("Enter" +" "+ size+ " "+ "numbers");
		for(int i=0;i<nums.length;i++)
		{
			nums[i] = Console.readInt();
		}

		int index;	//You need to declare the index variable here. see below

		for(int i =0;i<nums.length;i++)		
		{
			//int index =nums[i];
			index = nums[i];	//When you declare a variable inside a loop,
						//it gets destroyed once the loop has ended.
						//if you delcare the index variable here, then
						//it no longer exists, once this for loops has ended
			for(int j=i;j<nums.length;j++)
			{
				if(nums[j]== 5)
				{
					index = j;
				}
			}
		}      
	}
}