• Post Reply Bookmark Topic Watch Topic
  • New Topic

why a inner class cant have static variables?  RSS feed

 
Mohan Patidar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class InnerClassEx
{


public InnerClassEx()
{
getData();
}

public void getData()
{
Inner in=new Inner();
in.display();

}
public class Inner
{
static int y; //error it cant be why
static final int x=20;
public void display()
{
//x=20;
System.out.println(x);
System.out.println("Inner Class");
}
}
public static void main(String s[])
{
new InnerClassEx();
}
}
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Programming is also about attention to detail.
To quote what it says from the top of Ranch Office
This forum is intended for questions and comments about the web sites www.javaranch.com and www.coderanch.com.
It is not for questions about the Java language - that's what all our other forums are for.


This topic has been moved to a more appropriate forum. CarefullyChooseOneForum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!