[Solved] Java: Parameter list without comma

I’m guessing you’re new to programming, so I’ll give a quick explanation of what’s going on. If I’ve missed the point of your question entirely, I’m sorry.

This line:

public int compareWith(Choice anotherChoice){

is part of the Choice object. It takes another Choice object and compares it with itself. …or at least, that’s what I would expect. The code you provided:

public int compareWith(Choice anotherChoice)
   Choice choice1 = new Choice(0);
   Choice choice2 = new Choice(1);
   if ((this.type == 0)&&(anotherChoice.getType() == 1)){
        return -1;

is incomplete and I have no idea what choice1 and choice2 are supposed to be doing. The code I would expect to see would look more like

public int compareWith(Choice anotherChoice)
   if (this.type == anotherChoice.getType())
        return 0;
   return -1;

or something like that.

Does that help?


solved Java: Parameter list without comma