• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Don't understand why prints twice  RSS feed

 
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.
 
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.
 
Bartender
Posts: 1983
59
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!