Okay say I have a class:
public class ExampleClass() {
public void exampleClassMethod(ArrayList abcdefg> arrList) {
....
For the second part
1)tester(Object s)
method will accept all Types of Object because any Object in Java internally inherits from java.lang.Object. So tester((Object) abc);
not required at all.
2)Typecast abc to CustomClass1 using CustomClass1 custom = (CustomClass1)abc
. I hope it works.
3)You can use instanceOf
operator but I guess this is lot of overhead for the developer & makes the code unreadable. Use it only if required.