Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me in static keyword

 
premanand sreedharan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class test
{
static int i=10;
public static void main(String a[])
{
test t=new test();
System.out.println(" ans1"+i+"ans2"+t.i);
}
}

why does these two output differ? i got two different answers for this pls help me in this
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is different?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
What is different?


Maybe he means he gets 110 and 210?
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maybe he means he gets 110 and 210?


Wow Barry!

Premanand's wariness forced me to go and see the output and really at first I was surprised seeing output.






Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic