A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Method behaving differently
mvPrasad Regula
Ranch Hand
Joined: Sep 14, 2009
Posts: 42
posted
Feb 23, 2010 16:22:50
0
Why is the following code returning zero? If I call giveMeJ() directly in System.out.println, I am getting 10.
public class Main{ private int i = giveMeJ(); private int j = 10; private int giveMeJ() { return j; } public static void main(String args[]) { System.out.println((new Main()).i); } }
Prasad Regula
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
14
I like...
posted
Feb 23, 2010 16:46:41
0
Having ignored multiple warnings regarding your display name, your account has been closed.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
I agree. Here's the link:
http://aspose.com/file-tools
subject: Method behaving differently
Similar Threads
forward refrerences
another perplexing program
please explain why the compiler is not complaining and why the output is 0
Variable initialization
Method invoke
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter