hopefully basic question

package comparable.ex01;

publicclass gaTuextends JFrame

{

public poss[] initializePop()

{

//this bit makes an array of objects

return aPos;

}

publicvoid mak(poss[] tempAPos[])

{

outtext.append("a");

}

publicstaticvoid main(String[] args)

{

new gaTu();

}

private JTextArea outtext;

public gaTu()

{

makeInterface();

poss[] aPos = initializePop();

Arrays.sort(aPos);

mak(aPos);

}

publicclass possimplements Comparable

{

//blah blah normal class things

}

}

I'm sorry if a few things of the code seem to be missing but i didnt feel as though they were necessary.

the problem i am having is with the mak method and calling it, Im not sure exactly how to pass an array of objects to a method correctly.i am recieving this error on compile.

breed(comparable.ex.01.gaTu.poss[][])in comparable.ex01.ga.tu cannot be applied to (comparable.ex01.gaTu.poss[])

[2008 byte] By [regularjohna] at [2007-11-27 8:40:22]
# 1

> > public void mak(poss[] tempAPos[])

> {

>

not sure about the rest of your code, but I usually pass arrays of any kind like so:

public void whatEver(poss[] myPosses)

{

for (int i = 0; i < myPosses.length; i++)

{

..........

}

}

petes1234a at 2007-7-12 20:38:46 > top of Java-index,Java Essentials,Java Programming...
# 2

hey john,

public void mak(poss[] tempAPos[]) {

the above is same as

public void mak(poss tempAPos[][]) {

or

public void mak(poss[][] tempAPos) {

these are treating tempAPos as array of array, but it is an array only...

try

public void mak(poss tempAPos[]) {

or

public void mak(poss[] tempAPos) {

regards

i_virus

i_virusa at 2007-7-12 20:38:46 > top of Java-index,Java Essentials,Java Programming...
# 3

thanks , l have noticed an error in my first post. where the word breed is should read mak. however i have tried these before, and these arrays are arrays of my custom obeject, i tried the metods you both used

Am i calling the mak method like so mak(aPos);

and the initializePop()

method creates 4 objects in an array called aPos.

is this clearer?

Message was edited by:

regularjohn

Message was edited by:

regularjohn

regularjohna at 2007-7-12 20:38:46 > top of Java-index,Java Essentials,Java Programming...
# 4

sorry john,

i am not getting you...

> Am i calling the mak method like so

>

> mak(aPos);

is this a question to me or you are telling me?

> is this clearer?

and i am not getting you here also...

please let me know clearly what you mean...

regards

i_virus

i_virusa at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 5

im saying that i am calling the mak method like this

mak(aPos);

im declaring the method like so

public void mak(poss[] tempAPos[])

{

outtext.append("a");

}

still i am getting an error message;

mak(comparable.ex.01.gaTu.poss[][])in comparable.ex01.ga.tu cannot be applied to (comparable.ex01.gaTu.poss[])

but i cant see a problem with the way i have coded this

regularjohna at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 6

hey john,

i think i have told you not to declare this way...

> > public void mak(poss[] tempAPos[])

> {

try

> > public void mak(poss tempAPos[])

> {

cheers

i_virus

i_virusa at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 7

> im saying that i am calling the mak method like this

>

> mak(aPos);

>

> im declaring the method like so

> > public void mak(poss[] tempAPos[])

> {

> outtext.append("a");

> }

>

>

> still i am getting an error message;

> mak(comparable.ex.01.gaTu.poss[][])in

> comparable.ex01.ga.tu cannot be applied to

> (comparable.ex01.gaTu.poss[])

>

> but i cant see a problem with the way i have coded

> this

Have you read any of the posts above?

If you don't understand yet, get out your textbook and start reading. You have to know the basics to move on, and only you can do this.

Message was edited by:

petes1234

petes1234a at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 8
yes petes1234, thanks for your concern.
regularjohna at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 9
i_virus thanks your method worked, re-wrote that method again i must have missed something in my code.Much appreciated
regularjohna at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...
# 10
hey john,sometimes we make silly mistakes in life, and in coding we overlook things... nevermind...Enjoy!!!i_virus
i_virusa at 2007-7-12 20:38:47 > top of Java-index,Java Essentials,Java Programming...