Howdy, Im getting the "'.class expected" error and I dont know what to correct. The code is

import java.io.*;
public class TeamHeight
{
public static void main (String[] args)
   	throws IOException
	{
       	double[] height = new double[11];
		double sum = 0;
		System.out.println ("The size of the array: " + height.length);
		for (int i = 0; i < height.length; i++)
       	 	{
           
BufferedReader keyIn = new BufferedReader (new InputStreamReader(System.in));
        			System.out.print ("Enter the height of the player: ");
        			height = Double.parsedouble[](keyIn.readLine());
System.out.print ("Player " + (i+1) + ": ");
			height[i] = Integer.parseInt(keyIn.readLine());
			sum = sum + height[i];       
		 	}
		System.out.println ("The average height: " + (sum/11));
		System.out.println ();
	}
}

Thanks
-Airman

Have you compiled the code? That error usually relates to attempting to run a main method in a file that has not yet been compiled. If that was a compiler error, which line(s) give the error?

Have you compiled the code? That error usually relates to attempting to run a main method in a file that has not yet been compiled. If that was a compiler error, which line(s) give the error?

Nope the code is not compiled. This error occurs when i attempt to compile it.

The error is at the line:


BufferedReader keyIn = new BufferedReader (new InputStreamReader(System.in));
System.out.print ("Enter the height of the player: ");
height = Double.parsedouble[](keyIn.readLine());

You should read a value, parse it put in your array and then start over. You cannot have parsedouble[] (actually the correct version is parseDouble(args)). When you read a value, you cannot convert it to an array. Just put it to the next location in your array.

I mean:

double temp = Double.parseDouble(keyIn.readLine());

an then:

height[i] = temp;
commented: Good explanation +3

I changed the parse thing to

height = Double.parseDouble(KeyIn.readLine());

and now I get the error:

Incompatible types - found Double but expected Double[]

I changed the parse thing to

height = Double.parseDouble(KeyIn.readLine());

and now I get the error:

Incompatible types - found Double but expected Double[]

That's because height is an ARRAY but you here need a PRIMITIVE. You can use either a temp variable (as I described earlier), or try this: height = Double.parseDouble(...);

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.