This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question" Watch "question" New topic
Author

question

Tara Salehi
Greenhorn

Joined: Apr 10, 2008
Posts: 6
Hello to all
I have a question about JAVA
I know that we have internal in C# and we dont have it in java
but I need that definition in myprogram that is in java.how can I perform it ?
thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18916
    
  40

Originally posted by Tara Salehi:
Hello to all
I have a question about JAVA
I know that we have internal in C# and we dont have it in java
but I need that definition in myprogram that is in java.how can I perform it ?
thanks


Well, it's kinda hard to answer your question, since it depends on another definition in C#.

If you are looking to retrict access to the same package, you can either use the "protected" modifier which includes package access, or don't provide a modifier, which by default, is package access.

If you are looking to retrict access to the same jar file, there really isn't a close equivalent. The best option is probably to make the access public, but don't document it, so it won't be know outside of your jar file. (BTW, please correct me if I am wrong here -- there may be a cool technique that I don't know about)

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Henry Wong:

If you are looking to retrict access to the same jar file, there really isn't a close equivalent. The best option is probably to make the access public, but don't document it, so it won't be know outside of your jar file. (BTW, please correct me if I am wrong here -- there may be a cool technique that I don't know about)


No, that's about it. The Eclipse folks use a naming convention for this -- the contents of packages whose names contain the segment "internal" are not intended for use by other plugins. If there was anything better, they'd be using it!


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: question