GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Packages and Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packages and Classes" Watch "Packages and Classes" New topic
Author

Packages and Classes

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
I have a question. I have three classes that I want to put into one pacakge and I was wondering if there is anything in particular I should do. I want them all in:

package insy.java.hw7;

I have that at the beginning of all three classes (House, Home, OurDate).

I am getting the following 2 errors saying:

Home.java:5 'class' or 'interface' expected
package.insy.java.hw7;
^

Home.java:7: 'class' or 'interface' expected
import insy.java.OurDate;
^

Thank you for any comments, I am sure it is something stupid Thanks a lot!!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, that period in between the word "package" and the "insy" doesn't belong there. The second error may just be the result of the first. Note that the "package" line has to be the first non-comment line in the file, and the "import" lines have to come after any package line, but before anything else. For example




is a valid file with one of each.

Note, by the way, that if your class is in the insy.java package, you should not and need not import any other classes in that same package; they're available by default.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packages and Classes