Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Don't understand why prints twice  RSS feed

 
Urs Waefler
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code: It prints: 111 333 333. I do not understand why it prints two time 333.
 
Vasyl Lyashkevych
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a true.
When you run this line:         This line print that what we get from method parse.

you call method .

In the method parse you print really "333" here under varialbe



 
Urs Waefler
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value 333 ist assigned to the variable value; the variable global has the value 111. Finally there is a statement return value, which returns 333. Thus we have 111 333 333.
 
salvin francis
Bartender
Posts: 1529
26
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really dont understand the purpose of the program, maybe a little context might help ?

Your variable names are way too confusing and maybe they are confusing you too. While I dislike the code variables, I still refactored some variables and wrote a System.out.println instead:



output:


Hope this output clears your doubt.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!