wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes A stupid question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A stupid question" Watch "A stupid question" New topic

A stupid question

Hector Zoltan

Joined: Dec 31, 2006
Posts: 7
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

-= "A man can pretend to be serious, but cannot pretend to be witty" =-
Anton Uwe
Ranch Hand

Joined: Jan 10, 2007
Posts: 122
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

Joined: Oct 02, 2003
Posts: 11161

The API is your friend. Take a look at the .toString() methods.
[ January 16, 2007: Message edited by: Fred Rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hector Zoltan

Joined: Dec 31, 2006
Posts: 7

now I understand
I agree. Here's the link: http://aspose.com/file-tools
subject: A stupid question
Similar Threads
toString method and output
Why is this output ??
doubt in the advance for loop in java6
Object Comparison
Calling Superclass Methods and Forgetting to Use the Return Value