Simple package creation

I am using packages for the first time here and would like to know some basic understanding of them. I am using a Mac which shouldnt really matter, but anyway...I have a folder on my desktop called lab4, within this folder is another folder called csci1902 and a README.txt file, then inside the csci1902 folder is another folder called lab4. Inside this last lab4 folder are where my .java files are located. I was told that all I really need to do is put package csci1902.lab4; at the top of all my source code. Is this correct? and that is all? I have to do this so when we hand in the code, the TAs can run a script file and grade them all. With that at the top of my files, they will all be in that packge? Thank you.

kasey

[741 byte] By [kschinsa] at [2007-11-27 1:23:49]
# 1

Yes, all you need to do to put a class in a package is to put the package declaration line at the top of the file.

However, it is (IMO) better to choose appropriate package names, and organize you file tree to match your package names, than to create your package tree and simply name your files based on the directories they are in.

- Adam

guitar_man_Fa at 2007-7-12 0:14:02 > top of Java-index,Java Essentials,New To Java...
# 2
Have you studied the tutorial section on packages? http://java.sun.com/docs/books/tutorial/java/package/index.html
DrLaszloJamfa at 2007-7-12 0:14:03 > top of Java-index,Java Essentials,New To Java...
# 3
sounds good. yes i went over the tutorial and it makes some sense, so i appreciate the help. thanksk schins
kschinsa at 2007-7-12 0:14:03 > top of Java-index,Java Essentials,New To Java...