Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Rani Singh   on Jul 16 In Java Category.

  
Question Answered By: Emma Brown   on Jul 16

That doesn't work. You need to do:
Fruit f = new Fruit();
Fruit.SkinType st = f.new SkinType();
Fruit.SkinType.Color = st.new Color();

which is a pain in the posterior.

But another idea strikes me:

public class  Fruit {
public class SkinType {

public class color  {
private String color;

public Color(String c) {
color = c;
}
.
.
.
}
public static Color GREEN;

static {
GREEN = new Color("GREEN");
}
}
}

> For what its worth, you may want to consider not doing this as it
will
> severely prohibit reuse.
>
> Sincerely,
> Anthony Eden

What I want to do is (in c++ terminology) have a enumerated list that
is encapsulated inside another class.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on creating an instance of a member class - how do you do it? Or get search suggestion and latest updates.


Tagged: