Languages

Java create List of Strings in one line - how to do it?

3 points
Asked by:
Kate_C
19790

How can I create List of Strings without using multile line code in java?

I have List<String> like below:

List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
list.add("3");

Is it possible to do it in 1 line?

0 answers
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join