Bookmark Topic Watch Topic
  • New Topic

Error Returning in my toString  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Report post to moderator
To string Returns the last character doubled
How do i stop it from doubling the last number?
 
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Report post to moderator
How are you trying to print them? Can you please show us?
 
Sammie Hassett
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Report post to moderator

Tushar Goel wrote:How are you trying to print them? Can you please show us?



Sure I have a test code:
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is what i thought so.. It is printing 2 things: 1) println in the constructor and 2) toString()

in println you are printing whole string and in toString() last char is printing. So that's why you got 2 char in last.
 
Saloon Keeper
Posts: 4066
48
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Cross posted in http://www.coderanch.com/t/649175/java/java/string-printing-digits
 
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
And so I'm closing this thread, as discussion is proceeding nicely in the other one.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!