wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes using public class in other packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using public class in other packages" Watch "using public class in other packages" New topic
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: 10451
    
    8

@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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

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 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using public class in other packages