#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1

    Compiling class Rectangle in Eclipse


    I am a Java beginner using Eclipse v.4.3.1.
    In my textbook, I am instructed to construct a new object of type Rectangle with the code
    Code:
    public class RectangleTest {
    	public static void main(String[] args)
    	{
    		System.out.println(new Rectangle(5, 10, 20, 30));
    	}
    
    }
    However, the compiler tells me the Rectangle cannot be resolved to a type.

    What should I do?
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    You need to give the compiler the full path to the definition for the Rectangle class.
    All Java SE classes are in packages, for example: java.util. The package name is part of the full class name. The import statement points to the package a class is in.
    Find the package that the Rectangle class is in and add am import statement for it.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0
    Thank You. I was also wondering it.

IMN logo majestic logo threadwatch logo seochat tools logo