0
What is the purpose of "<>" in java?
I'm confused about this symbol. Is it used to define only data types of Lists?
8 Respostas
+ 3
When instantiating a generic type such as a List, Set or Map, this is used to specify what actual type is stored in that particular instance.
e.g. ArrayList<String> is a list of String.
<> is used when the type definition is not needed,or known implicitly e.g.
Entry<String, String> myEntry = new Entry<>("FirstItem", "A");
+ 2
Naveen Deenadayalan well, yes, and ArrayList implements List.
Furthermore, that's right, it is not only used for List, it is useful for any generics type. You can even create your own class with generics.
+ 1
It is not only used to represent data types of list, it is also used to represent arraylist in java
+ 1
can you give me some example program to create own class with generics
+ 1
ifl How they used in class?
can you give some example?
0
I didn't know anything about generic, so I googled it. Now my confusion is somehow clear.
Thanks to both of you! :)