ArrayList list =new ArrayList(); & ArrayList<Object> list = new ArrayList<Object>();
is both statement works same?is there any difference between them?
You can add objects to both the lists. Only place where it breaks is when you assign any other type safe ArrayList to ArrayList<Object>. Something like this
The difference was.. the compiler will claim you about he doens't know the type of objects will be in the first List.
anyway.. he assigns Object as Type but in the second case at least he know you provided this information.^^
Each of their nuggets of wisdom contracted to a sound bite: Joshua Bloch: Write Lots of Code; Chet Haase: Don't Put Your Entire Application in One Method; Masood Mortazavi: Start Simple and Keep Learning; Cay Horstmann: First, Don't Panic
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart: