• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A stupid question

 
Hector Zoltan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw this code:

public class Counter {
int i;
public String toString() { return Integer.toString(i); }
}

And I was wondering, how could he overload the Integer toString method with an i parameter? I think I'm missing something here...

Anyone could help me out here please?

thanks in advance
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer.toString(i) takes an int, the value of i in this case, and returns the String representation of this value.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API is your friend. Take a look at the .toString() methods.
[ January 16, 2007: Message edited by: Fred Rosenberger ]
 
Hector Zoltan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

now I understand
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic