tl;dr
In Java 21+:
strings.addFirst( "a" )
In earlier Java:
strings.add( 0, "a" )
List#addFirst
If the nested lists are modifiable, in Java 21+ we can simply add first element.
First, some example data.
List < List < String > > listOfListsOfStrings =
List.of(
new ArrayList <>( List.of( "Foo" ) ) ,
new ArrayList <>( List.of( "Bar" ) )
);
System.out.println( "listOfListsOfStrings = " + listOfListsOfStrings );
listOfListsOfStrings.toString() = [[Foo], [Bar]]
Then we prepend on each nested list.
listOfListsOfStrings.forEach( strings -> strings.addFirst( "a" ) );
listOfListsOfStrings.toString() = [[a, Foo], [a, Bar]]
By the way, if frequently inserting elements into a List
, consider using LinkedList
rather than ArrayList
. See When to use LinkedList over ArrayList in Java?.
Sequenced collections
The addFirst
method is part of the Sequenced Collections feature.
See JEP 431. And see also the good presentation by Stuart Marks.

Indeed, you might want to declare your list of lists to be of the more general type, a sequenced collection of sequenced collections.
SequencedCollection < SequencedCollection < String > > seqcolOfSeqcolOfStrings =
List.of(
new ArrayList <>( List.of( "Foo" ) ) ,
new ArrayList <>( List.of( "Bar" ) )
);
…
List<List<String>> base
, thenbase.forEach(l -> l.addFirst("a"));
should do (original sub-lists are changed,addFirst()
available since Java 21)l.add(0, "a")
.