• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

using public class in other packages

 
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
 
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.
 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
Boost this thread!