I\'m new with Java and I\'m having trouble understanding the constructor issue, I have looked at many tutorials and still I\'m having difficult to understand why we use construc
Yes a constructor has the same name as the Class
.
As long as the constructors have different signatures you can have as many as you want. The signature is what distinguishes one constructor from another...
public MyClass()
{
}
public MyClass(int a)
{
}
public MyClass(int a, int b)
{
}
public MyClass(String a)
{
}
public MyClass(int a, String b)
{
}
Those are all different because they have different signatures.