File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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: 11955

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:
subject: A stupid question
It's not a secret anymore!