• Post Reply Bookmark Topic Watch Topic
  • New Topic

modifier private not allowed  RSS feed

 
Amreek Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when i compile this code, it shows error 'Modifier private not allowed here'
i want to know what is reason behind this?

html file of applet



why we write .class extension in html file why we can't use .java file?
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Tutorial - Controlling Access to Members of a Class

Access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

At the top level—public, or package-private (no explicit modifier).
At the member level—public, private, protected, or package-private (no explicit modifier).

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere.
If a class has no modifier (the default, also known as package-private), it is visible only within its own package.
 
Luan Cestari
Ranch Hand
Posts: 172
C++ Redhat Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Jozsef Balazs wrote:Java Tutorial - Controlling Access to Members of a Class

Access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

At the top level—public, or package-private (no explicit modifier).
At the member level—public, private, protected, or package-private (no explicit modifier).

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere.
If a class has no modifier (the default, also known as package-private), it is visible only within its own package.


Ivan is right. I would answer your last question saying that Java Virtual Machine (JVM) process only Bytecodes that are the output of compiled code of your ".java" files. So, in the ".class" files there are more low level instructions (bytecode) to the JVM follow what you programmed. The JVM can also get the bytecode from some other ways (inside compress files like JAR, EAR, WAR, RAR, etc and also during the runtime).

That a look in those tutorials and training:
http://www.oracle.com/technetwork/java/compile-136656.html
http://www.oracle.com/technetwork/java/basicjava1-135508.html
http://www.oracle.com/technetwork/java/basicjava2-138746.html
http://docs.oracle.com/javase/tutorial/index.html (this one is very interesting to get a lot of experience )

Regards
Luan
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to make your class First private, what did you hope to accomplish with this?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!