arrays - What is the diamond operator in Java? -


this question has answer here:

i have arraylist type patient_class , arraylist type has been underlined in yellow , ide has mentioned "redundant type arguments in new expression (use diamond operator instead)".

my problem is: should use diamond operator instead? must? data loss or other problem when storing records arraylist?

here arraylist:

public class register_newpatient extends javax.swing.jframe {      public register_newpatient() {         initcomponents();         groupbutton();     }      public void groupbutton()     {         buttongroup bg1=new buttongroup();          bg1.add(rbopd);         bg1.add(rbinpatientcare);         bg1.add(rbboth);     }      all_error_handling checkerror = new all_error_handling();     jframe frame = new jframe();     static arraylist<patient_class>patientlist = new arraylist<patient_class>(); 

to honest have no idea diamond operator is.

don't worry. it's not evil. it's feature of java 7.

the purpose of diamond operator simplify instantiation of generic classes.

for example, instead of

list<map<integer,set<string>>> p = new arraylist<map<integer,set<string>>>(); 

with diamond operator can write only

list<map<integer,set<string>>> p = new arraylist<>(); 

if want know more , want use it, please have quick here , decide whether it's useful or not.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -