Problem with object

Hello

Suppose I have an object :

PassingPerson(name, nr);

It sends the name, nr to the method

private void PassingPerson(String name, String nr) {

Source code? etc....

}

How can I loop the object that it sends each time a new object with other argument to the method? For example

Fred 001

Fred 002

Fred 003

[376 byte] By [DavyPa] at [2007-11-27 9:06:30]
# 1

> Suppose I have an object :

>

> PassingPerson(name, nr);

That's a call to a poorly named method, not an object.

> How can I loop the object that it sends each time a

> new object with other argument to the method? For

> example

> Fred 001

001 is not a number but a String. So use a for loop, create your string using the loop's counter, and be done.

Although it's a dumb idea to use a String if you want to have a number.

CeciNEstPasUnProgrammeura at 2007-7-12 21:42:02 > top of Java-index,Java Essentials,Java Programming...
# 2
Is your means that the PassingPerson method is the constructor?
Stone.lia at 2007-7-12 21:42:02 > top of Java-index,Java Essentials,Java Programming...
# 3
> Is your means that the PassingPerson method is the> constructor?Constructors don't return void, though, and are invoked using "new".
CeciNEstPasUnProgrammeura at 2007-7-12 21:42:02 > top of Java-index,Java Essentials,Java Programming...
# 4

You have put the method name as the class name, hence it becomes a constructor. So this program doesn't compile.

Again, you are passing integer number to string so again compiler error.

If you want to make more instances using for loop, then take some variable, increment it by 1, name value is contstant for all, so doesn't matter.

KeDeSola at 2007-7-12 21:42:02 > top of Java-index,Java Essentials,Java Programming...