aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help me in static keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help me in static keyword" Watch "help me in static keyword" New topic
Author

help me in static keyword

premanand sreedharan
Greenhorn

Joined: May 06, 2007
Posts: 5
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

Joined: Feb 07, 2005
Posts: 2367
What is different?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Originally posted by Keith Lynn:
What is different?


Maybe he means he gets 110 and 210?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707

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,


cmbhatt
 
 
subject: help me in static keyword