0 votes
2 views
in Java by (10.2k points)

We create a Set as:

Set myset = new HashSet()

How do we create a List in Java?

1 Answer

0 votes
by (46.1k points)

To create and initialize Array in just one line in Java use:

        String[] coolStringArray = new String[]{"a" , "b" , "c"};

        System.out.println(" Array : " + Arrays.toString(coolStringArray));

    

        To create an ArrayList with three elements use:

        List<String> xStringList = new ArrayList<String>();

       xStringList.add("a");

       xStringList.add("b");

        xStringList.add("c");

To know more click here.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Dec 2, 2019 in Java by Anvi (10.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...