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: Pravat Jainukul   on Jul 16

Actually, you can by declaring that your inner class  is static.

public class Fruit {

public static class Color {

private String name;

private Color(String name) {
this.name = name;
}

public String toString() {
return name;
}

public static final Color RED = new Color("Red");

}

}

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: