In this Java programming quick tip tutorial, developers will learn how to remove a system property using the System.getProperty method. This technique is illustrated in the Java code example below:
*/ import java.util.*; public class DoubleBraces { public static void main(String[] args) { DoubleBraces doubleBraces = new DoubleBraces(); doubleBraces.proceed(); } private void proceed() { //Ideal way of initializing the arrayList List arrayList = new ArrayList(); arrayList.add("One"); arrayList.add("Two"); arrayList.add("Three"); //Initializing using the double braces way {{ }} List arrayList2 = new ArrayList() {{ add("One"); add("Two"); add("Three"); }}; System.out.println("ArrayList initialized the ideal way: " + arrayList); System.out.println("ArrayList initialized the double braces way: " + arrayList2); } } /*
Running this code example will result in the following output:
[root@mypc]# java DoubleBraces ArrayList initialized the ideal way: [One, Two, Three] ArrayList initialized the double braces way: [One, Two, Three]