• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused with System.out.print

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




stack.size()=5
Values are in stack = 12
Values are in stack = 23.6755
Values are in stack = Srinivas
Values are in stack = A
i=4
Employee =Srinivas : 163052 Employee =Srinivas : 163052



Employee out values are coming twice.Any one has idea why it's coming twice ?
when i give println everything is working fine .
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran your code and obtained this output

campbell@********-laptop:~/java$ java JavaStackExample
stack.size()=5
Values are in stack = 12
Values are in stack = 23.6755
Values are in stack = Srinivas
Values are in stack = A
i=4
Employee =Srinivas : 163052campbell@********-laptop:~/java$

I couldn't reproduce the error you suffered.

You are using the stack incorrectly; you are using it as a List. It is a bit of bad design that Stack extends Vector, but if you use it as a stack you should only use the push() pop() peek() and isEmpty() methods.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
out put is:


stack.size()=5
Values are in stack = 12
Values are in stack = 23.6755
Values are in stack = Srinivas
Values are in stack = A
i=4
Employee =Srinivas : 163052


so no double will come

 
reply
    Bookmark Topic Watch Topic
  • New Topic