royalcyber
asked on
polymorphic arrays and branching logic in Java
Hi experts,
Can anybody tell me what are polymorphic arrays and branching logic in Java ? Thanx in advance.
Can anybody tell me what are polymorphic arrays and branching logic in Java ? Thanx in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@tbeernot
>> Polymophic means: can contain different kinds of objects. So an array defined as having Objects (in Java) can contain Strings and Numbers mixed.
I don't think thats polymorphic whats so great about a object array containing different object, how can you use that array, you may land up getting many exception like ClassCastExcpetion, ArrayStorageException etc etc. when you are trying to extract those objects out of the array.
If i am wrong experts please correct me. :)
>> Polymophic means: can contain different kinds of objects. So an array defined as having Objects (in Java) can contain Strings and Numbers mixed.
I don't think thats polymorphic whats so great about a object array containing different object, how can you use that array, you may land up getting many exception like ClassCastExcpetion, ArrayStorageException etc etc. when you are trying to extract those objects out of the array.
If i am wrong experts please correct me. :)
I am sorry, but an polymorphic array is one that contains multiple objects. And yes, it is tricky to work with and that is why they added generics to Java 1.5 (to improve it, still not perfect). No one said polymorphic meant "no problems".
Strange points division.
You realize that Number, Strings and any other class in java (BaseClass, SubClass) is a subclass of Object? Hence an array of Objects can contain instances of any class.
You realize that Number, Strings and any other class in java (BaseClass, SubClass) is a subclass of Object? Hence an array of Objects can contain instances of any class.
Branching logic are the if and select statements.