• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inner class naming

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
Inner class can have same name as the outer class.
TRUE or FALSE
Seems answer is FALSE. Can somebody explain why?
Thanks
Laoniu
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a "namespace" conflict. The system needs to have a unique name for each class that it is working with. If two Classes have the same name the system can not properly keep track of which one each object is.
class Test{
class Test{ }
public static void main(String[] args]{
Test t1 = new Test(); // this is an object of type Test
Test t2 = new t1.Test(); //this is an object of type Test
}
}
 
laoniu gougou
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cindy:
It is true for general class. However, inner class will have the name like: Outer$Inner, is it true?
 
reply
    Bookmark Topic Watch Topic
  • New Topic