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[])
> > 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++)
{
..........
}
}
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
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
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
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
> 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