It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Can you explain me how the static works in this example? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can you explain me how the static works in this example?" Watch "Can you explain me how the static works in this example?" New topic
Author

Can you explain me how the static works in this example?

shoeb sayyed
Ranch Hand

Joined: Mar 14, 2010
Posts: 48


Thanks,
Shoeb
Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
The reason why you are getting the value of j as 4 is because ....in the following line :



you used an Conditional OR Operator ..this operator exhibit "short-circuiting" behavior, which means that the second operand is evaluated only if needed. In this case the first condition is i< 10 which is true ...so it won't check the second operand.....and that's the reason why you are getting the value of j as 4....

Hope this is the answer to your question...


Human Knowledge Belongs to the World.
- Vasiq Mz
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

Howdy shoeb, welcome to JavaRanch
Please UseCodeTags when you post a source code in future. It's unnecessarily hard to read the code otherwise.
For now, I've added the code tags on your post for you.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
shoeb sayyed
Ranch Hand

Joined: Mar 14, 2010
Posts: 48
Hey thanks

i would remember that next time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can you explain me how the static works in this example?
 
Similar Threads
what is the logic behind this
javaprogramming
Urgent help needed
basics: return value to main
IS this question good? why