I can't figure out why i'm getting an ambiguous error. This is a sample code of what I have:
public class MyString{
//Data:
private char[] theString;
//constructors:
public MyString(){ // default constructor
}
public MyString(String s){ // parameterized constructor
}
public MyString(char[] s){ // parameterized constructor
}
public MyString(MyString s){ // copy constructor
}
//A method that calls a constructor:
public MyString foobar(){
return new MyString(theString);
}
}
The above generates this error when foobar() is called from somewhere else:
./MyString.java:15: reference to MyString is ambiguous, both method MyString(char[])
in MyString and method MyString(theString) in MyString match
return new MyString(theString);
^
Any ideas why?