🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › String.html
String (Java SE 17 & JDK 17)
April 21, 2026 - The class String includes methods for examining individual characters of the sequence, for comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping is based on the Unicode Standard version specified by the Character class. The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › List.html
List (Java SE 17 & JDK 17)
April 21, 2026 - This method also accepts a single array as an argument. The element type of the resulting list will be the component type of the array, and the size of the list will be equal to the length of the array. To create a list with a single element that is an array, do the following: String[] array = ...
🌐
javaspring
javaspring.net › blog › java-17-list
Mastering Java 17 Lists: A Comprehensive Guide — javaspring.net
If you need to modify the list while iterating, use an Iterator or a ListIterator which provides safe ways to modify the list during iteration. Java 17 lists are a powerful and versatile part of the Java Collections Framework.
🌐
Baeldung
baeldung.com › home › java › java string › converting a list to string in java
Converting a List to String in Java | Baeldung
July 30, 2026 - If our elements in the List aren’t subclasses of CharSequence, we can first convert the List to a List<String>, and then pass it to String.join():
🌐
Java Concept Of The Day
javaconceptoftheday.com › home › java new string methods – from java 8 to java 17
Java New String Methods - From Java 8 To Java 17
February 26, 2022 - import java.util.Arrays; import java.util.List; public class Java8StringMethods { public static void main(String[] args) { String languages = String.join("_", "Java", "HTML", "Python", "CSS", "PHP"); System.out.println(languages); List<String> languageList = Arrays.asList("Java", "HTML", "Python", "CSS", "PHP"); languages = String.join(", ", languageList); System.out.println(languages); } }
🌐
freeCodeCamp
freecodecamp.org › news › how-to-initialize-a-java-list
How to Initialize a Java List – List of String Initialization in Java
April 14, 2023 - The add() method can be used to add elements to the end of a list, which makes it a convenient way to initialize a list with some initial values. Here is an example of how to use the add() method to initialize a Java list:
🌐
iO Flood
ioflood.com › blog › java-list-of-strings
Java List of Strings: Creation, Manipulation, and More
February 27, 2024 - It’s part of the Java Collections Framework and is widely used because of its flexibility and functionality. An ArrayList is a resizable array that grows automatically when more elements are added to it. It also shrinks when elements are removed. Here is a simple example of how to create a list of strings using the ArrayList class:
Top answer
1 of 12
892

If you check the API for List you'll notice it says:

Interface List<E>

Being an interface means it cannot be instantiated (no new List() is possible).

If you check that link, you'll find some classes that implement List:

All Known Implementing Classes:

AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector

Some of those can be instantiated (the ones that are not defined as abstract class). Use their links to know more about them, I.E: to know which fits better your needs.

The 3 most commonly used ones probably are:

 List<String> supplierNames1 = new ArrayList<String>();
 List<String> supplierNames2 = new LinkedList<String>();
 List<String> supplierNames3 = new Vector<String>();

Bonus:
You can also instantiate it with values, in an easier way, using the Arrays class, as follows:

List<String> supplierNames = Arrays.asList("sup1", "sup2", "sup3");
System.out.println(supplierNames.get(1));

But note you are not allowed to add more elements to that list, as it's fixed-size.

2 of 12
207

Can't instantiate an interface but there are few implementations:

JDK2

List<String> list = Arrays.asList("one", "two", "three");

JDK7

//diamond operator
List<String> list = new ArrayList<>();
list.add("one");
list.add("two");
list.add("three");

JDK8

List<String> list = Stream.of("one", "two", "three").collect(Collectors.toList());

JDK9

// creates immutable lists, so you can't modify such list 
List<String> immutableList = List.of("one", "two", "three");

// if we want mutable list we can copy content of immutable list 
// to mutable one for instance via copy-constructor (which creates shallow copy)
List<String> mutableList = new ArrayList<>(List.of("one", "two", "three"));

Plus there are lots of other ways supplied by other libraries like Guava.

List<String> list = Lists.newArrayList("one", "two", "three");
🌐
Java2Blog
java2blog.com › home › core java › string › initialize list of string in java
Initialize List of String in java - Java2Blog
May 9, 2021 - Finally, java has introduced a of() method in List class to initialize list with values in java 9. ... You can obviously initialize ArrayList with new operator and then use add method to add element to the list. ... You can use guava library as well. ... Here is the complete example. ... That’s all about how to initialize List of String in java.
Find elsewhere
🌐
Processing
processing.github.io › processing-javadocs › core › processing › data › StringList.html
StringList
Functions like sort() and shuffle() always act on the list itself. To get a sorted copy, use list.copy().sort(). ... Construct a StringList from a random pile of objects. Null values will stay null, but all the others will be converted to String values. public StringList(java.lang.Iterable<java.lang.String> iter)
🌐
DEV Community
dev.to › emilossola › exploring-stringlist-in-java-a-comprehensive-guide-3lok
Exploring StringList in Java: A Comprehensive Guide - DEV Community
July 7, 2023 - Additionally, you can also use a loop, such as a for loop or a foreach loop, to iterate through all the elements in a StringList and access them one by one. This can be useful when you need to perform an operation on each element or search for a specific element in the list. import java.util.ArrayList; import java.util.List; public class StringListExample { public static void main(String[] args) { // Creating a StringList List<String> myList = new ArrayList<>(); myList.add("Apple"); myList.add("Banana"); myList.add("Orange"); // Using a for loop System.out.println("Using a for loop:"); for (int i = 0; i < myList.size(); i++) { String element = myList.get(i); System.out.println("Element at index " + i + ": " + element); } // Using a foreach loop System.out.println("\nUsing a foreach loop:"); for (String element : myList) { System.out.println("Element: " + element); } } }
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
Elements in an ArrayList are actually objects. In the examples above, we created elements (objects) of type "String". Remember that a String in Java is an object (not a primitive type). To use other types, such as int, you must specify an equivalent wrapper class: Integer.
🌐
Medium
medium.com › @mgm06bm › java-string-collections-list-vs-array-choosing-the-right-option-57e14bc00466
Java String Collections: List vs. Array —Understanding Their Differences | Mehmood | Medium
January 4, 2024 - import java.util.List; List<String> listOfString = new ArrayList<>(); listOfString.add("Java"); listOfString.add("List"); listOfString.remove(0); system.out.println(listOfString); //[List]
🌐
javaspring
javaspring.net › blog › java-17-string
Java 17 Strings: A Comprehensive Guide — javaspring.net
This blog post aims to provide a detailed overview of Java 17 strings, including their fundamental concepts, usage methods, common practices, and best practices.
🌐
Sentry
sentry.io › sentry answers › java › how do i initialize a `list` object in java?
How do I initialize a `List<String>` object in Java? | Sentry
November 15, 2024 - In this example, myList is an instance of ArrayList that holds String elements. The add() method adds items to the list. Alternatively, you can use Arrays.asList() to initialize a List with predefined values: import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<String> myList = Arrays.asList("Apple", "Banana", "Cherry"); System.out.println("My List: " + myList); } }
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › util › StringJoiner.html
StringJoiner (Java SE 17 & JDK 17)
April 21, 2026 - StringJoiner is used to construct a sequence of characters separated by a delimiter and optionally starting with a supplied prefix and ending with a supplied suffix.
🌐
Medium
medium.com › @teamcode20233 › exploring-stringlist-in-java-a-comprehensive-guide-ef5ef6320c7b
Exploring StringList in Java: A Comprehensive Guide | by Teamcode | Medium
July 7, 2023 - To create a StringList, we need to first import the required package, which is java.util, and then declare an instance of the StringList class. This can be done by using the ArrayList class, which is a commonly used implementation of the StringList interface. Once the StringList instance is created, we can perform various operations such as adding, removing, or accessing elements in the list.
🌐
GeeksforGeeks
geeksforgeeks.org › java › initializing-a-list-in-java
Initializing a List in Java - GeeksforGeeks
Import the required classes from java.util. Declare a List using the List interface.
Published: 2 weeks ago
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java 8 - Converting a List to String with Examples - Java Code Geeks
July 5, 2021 - A quick guide to convert List to String in java using different methods and apache commons api with examples.
Top answer
1 of 7
124

There are various options. Personally I like using Guava:

List<String> strings = Lists.newArrayList("s1", "s2", "s3");

(Guava's a library worth having anyway, of course :)

Using just the JDK, you could use:

List<String> strings = Arrays.asList("s1", "s2", "s3");

Note that this will return an ArrayList, but that's not the normal java.util.ArrayList - it's an internal one which is mutable but fixed-size.

Personally I prefer the Guava version as it makes it clear what's going on (the list implementation which will be returned). It's also still clear what's going on if you statically import the method:

// import static com.google.common.collect.Lists.newArrayList;
List<String> strings = newArrayList("s1", "s2", "s3");

... whereas if you statically import asList it looks a little odder.

Another Guava option, if you don't want a modifiable-in-any-way list:

ImmutableList<String> strings = ImmutableList.of("s1", "s2", "s3");

I typically want to either have a completely mutable list (in which case Lists.newArrayList is best) or a completely immutable list (in which case ImmutableList.of is best). It's rare that I really want a mutable-but-fixed-size list.

2 of 7
42

Java 9+

Java 9 introduces a convenience method List.of used as follows:

List<String> l = List.of("s1", "s2", "s3");

Java 8 and older

Here are a few alternatives:

// Short, but the resulting list is fixed size.
List<String> list1 = Arrays.asList("s1", "s2", "s3");

// Similar to above, but the resulting list can grow.
List<String> list2 = new ArrayList<>(Arrays.asList("s1", "s2", "s3"));

// Using initialization block. Useful if you need to "compute" the strings.
List<String> list3 = new ArrayList<String>() {{
    add("s1");
    add("s2");
    add("s3");
}};

When it comes to arrays, you could initialize it at the point of declaration like this:

String[] arr = { "s1", "s2", "s3" };

If you need to reinitialize it or create it without storing it in a variable, you do

new String[] { "s1", "s2", "s3" }

If the string constants are may though, it would look like

String[] arr = { "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10",
                 "s11", "s12", "s13" };

In these cases I usually prefer writing

String[] arr = "s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13".split(",");