• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using public class in other packages

 
abhinav sood
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic