Top community members
All Questions Ask Question

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you think you have some skills to help others

help someone and become a part of our community - List Q & A

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

0 answers
1 points

How can I create one element List of Strings in 1 line?

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

Is is possible to do it in 1 line?

When I have method which would return this array, it'd take 3 lines:

public List<String> createList() {
    List<String> list = new ArrayList<>();
    return list;

It'd be great if it could be done in 1 line instead of 3.

0 answers

Suggested questions:

Suggested findings

Let's do the work and have some fun
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way. ❤ 💻 🙂
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    we will help you. 👍 ✔ 🦄
Read more