I came across a method with a parameter list where the parameter were not separated by comma and no declaration of the variable type:
public int compareWith(Choice anotherChoice){
Later these parameters were called without any further declaration inside the body in an if-else statement in combination with another method:
if ((this.type == 0)&&(anotherChoice.getType() == 1)){
return -1;
This is a brief summary of the entire class:
public class Choice
{
private int type;
public Choice(int type)
{
//initialize the "type" instance varialble
this.type = type;
}
public int getType()
{
return type;
}
public int compareWith(Choice anotherChoice)
{
Choice choice1 = new Choice(0);
Choice choice2 = new Choice(1);
if ((this.type == 0)&&(anotherChoice.getType() == 1)){
return -1;
The program goes on. I really don't get the link between anotherChoice, getType() and choice2. It is a task in an online course and the program works as intended, but I don't know why.