• Post Reply Bookmark Topic Watch Topic
  • New Topic

can you explain this to me about packages  RSS feed

 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put a package statement with that name at the top of every source file that contains the types (classes, interfaces, enumerations, and annotation types) that you want to include in the package.

The package statement (for example, package graphics;) must be the first line in the source file. There can be only one package statement in each source file, and it applies to all types in the file.

ok...

package statement? where does that go? is it just a source file with comments?  every source file? every class file?
sorry find this a bit confusing..can somebody clarify




 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry was being thick... yes you have
package com.fds.myGraphics a the top of every source file that belongs to that package...duh!
 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package names are all in lower case
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put all those classes into a folder called resources and compile them with javac *.java. Navigate to the parent folder with cd .. then print one of the .class files, e.g. javap resources.MyUtilities
You sho‍uld see the class is called resources.MyUtilities not MyUtilities.
Note: I intended those classes to be utility classes and they never need to be instantiated, hence the private constructors. You would usually use an annotation for author rather than that block comment.
 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks campbell

what is
import ...;

never seen that before
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely you have seen import declarations? The ellipsis ... simply means I am missing code out. It is not part of correct Java® code, so you will have to change that before you try to compile the code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!