Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what does this line mean..(Defining Packages)

 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading about packages and i came across this statement


The package name is saved in the java byte code for the types contained in the package.


Please could someone explain
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Iam not sure that this is the correct explanation for your question but i understood like this the line says
quote:
--------------------------------------------------------------------------------

The package name is saved in the java byte code for the types contained in the package.

--------------------------------------------------------------------------------

Class we have defined can say as new data type that is object is the variable of the class datatype. So i think this line means package is contains so many datatypes that is classes. How we can access the class in a package by specifying like this package.classname right!
so here package name is using to access the userdefined data type that is class. That package name JVM stores it in byte code. I think u got some thing.
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wasnt able to understand an iota ...

Reagards
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, the "types contained in the package" refers to interfaces and classes that are declared in a package. The "byte code" refers to the data that is stored in the .class file that you get when you compile a .java file that contains such a class or interface. So say you have a class named MyClass with the source code in a file named MyClass.java. Also, you declare MyClass to be in the package mypackage. When you compile MyClass.java, javac generates a file named MyClass.class. Somewhere in this file, the compiler stores the package name (i.e. mypackage). I am willing to bet that somewhere in Sun's documentation, it specifies the exact location of the package name in the .class file.

HTH

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic