Double Brace Initialization in Java for List Collection

This tutorial is all about Double Brace Initialization in Java for List Collection

. In this tutorial you will learn How to use Double Brace Initialization in Java for List Collection. List Collection is very useful when you want to store a lot of data in a single array or datatype. it help you organize your data and allow you to call then easily just by accessing its index

. basically, a list collection stores elements by insertion order (either at the end or at a specific position in the list). A list maintains indices of its elements so it allows adding, retrieving, modifying, removing elements by an integer index (zero-based index; the first element is at 0-index, the second at 1-index, the third at 2-index, and so on). The following picture illustrates a list that stores some String elements. follow all the steps below to complete this tutorial.

Double Brace Initialization in Java for List Collection steps

 

The first step is to, create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. After that you need to create you class by right clicking the Source Packages and then click the New – Java Class

After that you need to import these packages

import java.util.ArrayList;

import java.util.List;

above your class and

copy paste the code below:

[java]

List<Integer> values = new ArrayList<Integer> ()

{{

add (57);

add (43);

add (54);

}};

for (int i: values) {

System.out.println(i);

}

[ /java]

Then you’re done. Run your project and see if it works.

About The Double Brace Initialization In Java

Project Name: Double Brace Initialization
Language/s Used: JAVA
Database: None
Type: Desktop Application
Developer: IT SOURCECODE
Updates: 0
Double Brace Initialization In Java– Project Information

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]

Facebook: facebook.com/RyyanSalem

Contact No.: +639098911050

Ryan A. Salem

BSIT Graduate, soon to be MIT.

Java Developer / System Developer

Related topic(s) that you make like:

1.) How to use Word Count in Java Tutorial using Netbeans IDE
2.) Java Arraylist

Leave a Comment