• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confused with System.out.print

 
srinivas srinivasmeenavalli
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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 .
 
Campbell Ritchie
Sheriff
Pie
Posts: 49845
70
  • Mark post as helpful
  • send pies
  • 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.
 
Debasis behera
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic