Array

Ok I'm stumped and just can't think of it. How do you set up a java class where you can pass it an array it does something with it and returns a new one?

[162 byte] By [mark07a] at [2007-11-27 11:24:58]
# 1

> Ok I'm stumped and just can't think of it. How do

> you set up a java class where you can pass it an

> array it does something with it and returns a new one?

public int[] doSomethingWith(int[] array) {

int[] newArray = array.clone();

// do that voodoo with newArray...

return newArray ;

}

[EDIT] I missed the part about return a *new* array. Good Lord; my return type was messed up, too. More coffee...

~

yawmarka at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...
# 2

public String[] someMethod(String[] someArray) {

String[] s = new String[10];

. . . populate . . .

return s;

}

jbisha at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...
# 3

>

> [EDIT] I missed the part about return a *new* array.

> Good Lord; my return type was messed up, too. More

> coffee...

>

> ~

...and the Good Lord said, "Let there be Java!"

jbisha at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...
# 4

> ...and the Good Lord said, "Let there be Java!"

Indeed! :o)

~

yawmarka at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...
# 5

lol thanks ya I'm on my fourth cup...still isn't helping

mark07a at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...
# 6

> lol thanks ya I'm on my fourth cup...still isn't

> helping

Don't give up! I read in Sience et Vie that drinking coffee makes us smarter! I'm on my third one and still counting

;)

Manuel Leiria

manuel.leiriaa at 2007-7-29 16:01:39 > top of Java-index,Java Essentials,Java Programming...