This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to instantiate a Class with the same name as an Inner Class?

 
Sasha Ruehmkorf
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
A very small problem, but I cannot find a solution:
 
Suman Sharma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sasha,
I tried your example. This is how it works:

File: In.java

package abc;

public class In {

In() {
System.out.println("instantiating outer In class");
}

public static void main(String[] args ){

Out o = new Out();

o.method();

}

}

File: Out.java

package abc;

class Out {

void method(){
abc.In i = new abc.In();//instantiating outer In class

In in = new In(); // instantiating inner In class
}

class In
{
In() {
System.out.println("instantiating inner In class");
}
}
}

Output is:

instantiating outer In class
instantiating inner In class
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my take on this.

separate In class:


Fubar1 class w/ internal In class:

[ May 09, 2007: Message edited by: pete stein ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic