| Author |
using public class in other packages
|
abhinav sood
Greenhorn
Joined: Aug 05, 2011
Posts: 9
|
|
now its giving thee output temp2 ,temp1,temp2
nw i want to know temp1 class is public so how we can access it in some other package
|
 |
Callum Ludwig
Greenhorn
Joined: Feb 20, 2011
Posts: 13
|
|
Temp1 is an inner class of Temp2, so I think it can only be accessed via the public class Temp2.
I'm not strong on inner classes as I don't really like the use of them in code, so I could be wrong.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
@Abhinav,
In future, while posting code, please UseCodeTags
I have added them to your original post for now. As you can see, they make the code much more easier to read and understand
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Callum Ludwig wrote:Temp1 is an inner class of Temp2, so I think it can only be accessed via the public class Temp2.
Looking at the code above, I don't see that class Temp1 is an inner class of class Temp2.
abhinav sood wrote:nw i want to know temp1 class is public so how we can access it in some other package
In your code above class Temp1 is not public. Since it's not public, it cannot be directly accessed from another package.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: using public class in other packages
|
|
|