aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 10909

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
Similar Threads
doubt in the advance for loop in java6
Object Comparison
Why is this output ??
toString method and output
Calling Superclass Methods and Forgetting to Use the Return Value