This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes a doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a doubt" Watch "a doubt" New topic

a doubt

ranjan sarkar

Joined: Jun 30, 2008
Posts: 7
class name
{public static void main(String[] args)
{int a=30;


gives something unexpected output.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
That output is correct. See this recentthread
ranjan sarkar

Joined: Jun 30, 2008
Posts: 7
but i need the perfect explanation.
please help me out
Henry Wong

Joined: Sep 28, 2004
Posts: 18507

Originally posted by RANJAN SARKAR:
but i need the perfect explanation.
please help me out

What is not "perfect" about the explanation? The links explains it to the full detail.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11153

it would also help, generally speaking, if you would explain what YOU think the output should be. Many people here will look at that and think "30 is exactly what I'd expect the output to be."

at that point, they then have to try and guess what you think the output should be, which can lead to all kinds of trouble.

if you say "Well, i think THIS should be the output, and here's WHY", it's much easier for someone to reply with "well, you make a false assumption HERE, and your logic is wrong THERE".

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ryan James

Joined: Apr 18, 2007
Posts: 15
I'd imagine he think the output should be 31, having set 'a' at 30 and then assuming the a++ will add one.
Consider Paul's rocket mass heater.
subject: a doubt
Similar Threads
Average age of Ranchers
Regarding salary.
How old are you ?
Cool Names for Bands/Artists
how to limit number of characters in the text box