A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
help me in static keyword
premanand sreedharan
Greenhorn
Joined: May 06, 2007
Posts: 5
posted
May 08, 2007 06:20:00
0
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: 2341
posted
May 08, 2007 06:27:00
0
What is different?
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
May 08, 2007 06:34:00
0
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
posted
May 08, 2007 06:44:00
0
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
I agree. Here's the link:
http://aspose.com/file-tools
subject: help me in static keyword
Similar Threads
jiris mock question
NEED CERTIFIED GUYS HELP!!
Variable shadowing
compile error
HFSJ chapter3 page 76
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter