I get the error test cannot be resolved to a type here

test[] arrayOftest = new test[ 3 ];

- ideas or help?

public class Test {
   public static void main( String args[] )
   {
      Point point = new Point( 3, 3 );          
      Square square = new Square( 7, 7, 7 );  
      Cube cube = new Cube( 2.2, 3 , 3  ); 

      test[] arrayOftest = new test[ 3 ];
      String result = "";

      arrayOftest[ 0 ] = point;
      arrayOftest[ 1 ] = square;
      arrayOftest[ 2 ] = cube;  
   
      result += point.getName() + ": " +
                    point.toString();
   
      result += "\n" + square.getName() + ": " + 
                    square.toString();
   
      result += "\n" + cube.getName() + ": " +
                    cube.toString();
      
      for ( int i = 0; i < 3; i++ ) {
         result += "\n" + arrayOftest[ i ].getName() +
            ": " + arrayOftest[ i ].toString();
          result += "\n" + "Area = " + 
          arrayOftest[ i ].area();
         result += "\n" + "Volume = " +
         arrayOftest[ i ].volume();
      }

      JOptionPane.showMessageDialog( 
            null, result, "Shapes",
            JOptionPane.INFORMATION_MESSAGE );   
      System.exit( 0 );  
   }
}

Recommended Answers

All 4 Replies

Things are case-sensitive in Java.

doh!

Thanks

I have seen this error message in java a lot of times: "MyClass cannot be resolved to a type". It took always long time for me to correct the mistake. This error message means, that the program cannot recognize MyClass as a type. The cause of the problem can be that you have not "import"-ed the package that contains MyClass. So to solve the problem, you have to write:
"import myProject\PackageOfMyClass\MyClass;"
I hope it helped.

In my previous post I wrote "\" signs instead of "." So i have to correct myself. In my previous comment the correct form is:
"import myProject.PackageOfMyClass.MyClass;"

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.