I have an array containing elements, each having 3 parameters (int, float and string). I followed the explanations to print an array using the toString method but I get the error "the method must return a result of type String" at this line:
public String MyObject(int a, float b, String c)
Here is my code:
public class MyObject
{
public int a;
public float b;
public String c;
public String MyObject(int a, float b, String c)
{
this.a = a;
this.b = b;
this.c = c;
}
@Override
public String toString()
{
return ("a="+a+" b="+b+" c="+c);
}
}
ArrayList<MyObject> myArrayList = new ArrayList<MyObject>();
void setup()
{
size(100, 60);
myArrayList.add(new MyObject(1, 4.5, "a"));
myArrayList.add(new MyObject(2, 5.8, "b"));
myArrayList.add(new MyObject(3, 1.3, "c"));
System.out.println(myArrayList);
myArrayList.removeAll(myArrayList);
}
I don't understand why I get this error since the toString method writes out the int and the float.
Could anyone give me a hint on how to solve this ?
Thanks for your help