import java.io.*;
class ArrayGet
{	
	int[] a = new int[20];
 	
	void FindMin(int[] a)
	{	
		int min=a[0];
		for(i=0;i<=10;i++)
		{
		if(a[i]<min)
		min=a[i];
		}
		
		System.out.println("Thr smallest element in the array"+min);
		
	}
	void Display()
	{
	for(int i=0;i<10;i++)
		{
		System.out.println("The elements in array are "+ a[i]);
		}
	}
	void GetMethod()
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try
		{
		System.out.println("Enter the value");
		for (int i = 0; i < 10; ++i)	
		{
			
		a[i] = Integer.parseInt(br.readLine());	

		}

		Display();	
		FindMin(int[] a);
		
		}
		catch(IOException e)
		{
		System.out.println("Error");

		}
	}

public static void main(String args[]) 
{ 

	 ArrayGet aa=new ArrayGet();
	 aa.GetMethod();
	 	

}
}

This is my Code i am trying to find a smallest element in the array.While passing array elements i am getting .Class Expected error please help me out in this regard

Recommended Answers

All 4 Replies

1. code tags
2. indentation.
3. full error message and line number

Follow the points mentioned by JamesCherrill

By the way your call to method FindMin is

FindMin(int[] a);

You do not make method call with the type specifiers. Just pass the parameters to the method like,

FindMin(a);

NoCodeTagError at line 1, program terminated

commented: lol +4

Not to mention that you didn't even need to pass it as parameter because you already had it:

class ArrayGet
{
   [B]int[] a = new int[20];[/B]
..
}

In the same way you call the Display() with no arguments and it takes the correct global array a[], the same you will call the FindMin() . Remove the argument from the declaration. You already have the array inside it.

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.