Is it advised to use typecasting of null to specific objects and using it in the constructor decreases the quality of code in anyway I'm doing this in the below scenario.
The Actual constructor are like this:
SomeListener(Fragment1 fragment1,String someValue){}
SomeListener(Fragment2 fragment2,String someValue){}
Now when I use this constructor as follows I am getting an error that it is ambiguous and it matches both of above constructors
SomeListener sml = new SomeListener(null,"value");
So what I did was this:
SomeListener sml = new SomeListener((Fragment2)null,"value");
Is this good way of coding or is there a better solution ? Will this solution cause any issue in runtime?
nulllike that? What happened? (It's fine.) You can easily tell whether it will throw an exception or not by just trying it - or reading the JLS, of course.