java - When we use Referrence type and Object Type -
this question has answer here:
- what mean “program interface”? 29 answers
i having doubt regarding arraylist , list. in case should use arrarylist like:
arraylist obj = new arraylist(); and in case should use list interface.
list obj = new arraylist(); after googling , study found nothing... please let me know difference between them.
thanks in advance :-)
if need call method specific implementation, use implementation.
when write :
list obj = new ... //arraylist() or linkedlist() the compiler knows obj list. hence, cannot use methods specific 1 implementation.
for example, if need access last element of linkedlist, need declare :
linkedlist = obj = new linkedlist(); now, obj linkedlist. hence, can use obj.last().
Comments
Post a Comment