Thursday, January 17, 2019

Why not List<String> listString = new ArrayList<String>(); 
You can assign an ArrayList<String> to a List<String> reference variable, but you can never assign an object with one generic type to an object with another generic type, no matter what inheritance there is.
Above code gives compile time Error "Type mismatch: cannot convert from ArrayList<String> to List<Object>".



Note:
Object o1=new String();  -> Possible (Upcasting and Automatic in Java)
Stringo1=new Object ();  -> Not Possible

0 comments:

Post a Comment

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts