4

Let's say I have this code:

public class A{
    public A(String b){}
    public A(Cursor c){}
    public A(SomeClass n){}
}

Now I want to create an instance of A but I don't know which constructor will select when the only parameter is null:

A someA = new A(null);

How should I manage this and figure it out ?

UPDATE

I have test this, it wont be compile with null but when I use a null object it will consider what is type of object like:

String n = null;
A someA = new A(n);

it will execute public A(String b){}

Is that safe ?

Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127
Pejman
  • 2,442
  • 4
  • 34
  • 62

1 Answers1

0

It ll result in compilation error, as the method call is ambiguous.

Soumitri Pattnaik
  • 3,246
  • 4
  • 24
  • 42