You have forgotten to give the variable a name? Both of these work.

String[][] array = {emptyArr, filledArr, moreFilledArr};
String[][] array = new String[][] {emptyArr, filledArr, moreFilledArr};

I recommend you to go through the basic Java syntax specification and tutorials. Start with The Java Tutorials by Oracle Corp, free of cost.

Answer from Nikolas on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - A String Array in Java is an array that stores string values.
🌐
W3Schools
w3schools.com › java › java_arrays.asp
Java Arrays
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To declare an array, define the variable type with square brackets [ ] : ... We have now declared a variable that holds an ...
Discussions

How do I determine whether an array contains a particular value in Java? - Stack Overflow
I don't understand this code. You sort the array 'strings' and use the same (sorted) array in both calls to binarySearch. How can that show anything except HotSpot runtime optimization? The same with the asList.contains call. You create a list from the sorted array and then does contains on ... More on stackoverflow.com
🌐 stackoverflow.com
In Java, how do static arrays of Strings work? Strings are arrays of characters, so when the array of Strings is initialized with a given size, how does Java know how much memory to allocate?
It's really just an array of references (this means 32 or 64 bit addresses depending on the platform), no memory is allocated for the string objects. More on reddit.com
🌐 r/learnprogramming
9
1
December 16, 2022
In Java, you may convert a string to an array.
I have a string array that says "ABCD", "EFGH", "IJKL", and "MNOP". I'm reversing the array as well as individual strings inside the array, and I expect the ... More on forum.qt.io
🌐 forum.qt.io
3
0
December 1, 2022
[Java] Swap two strings in an array
Well, for one, you never actually swap them in the array. You are only swapping the values of kid1 and kid2. In your loop, you should find the indices of kid1 and kid2. Then you should swap the contents of the array at those two locations. More on reddit.com
🌐 r/learnprogramming
3
2
February 19, 2014
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array
Java String Array | DigitalOcean
August 3, 2022 - Java String array is used to hold fixed number of Strings. String array is very common in simple java programs, specially among beginners to java and to test some specific scenarios. Even java main method argument is string array - public static void main(String[] args).
Top answer
1 of 16
3431
Arrays.asList(yourArray).contains(yourValue)

Warning: this doesn't work for arrays of primitives (see the comments).


Since java-8 you can now use Streams.

String[] values = {"AB","BC","CD","AE"};
boolean contains = Arrays.stream(values).anyMatch("s"::equals);

To check whether an array of int, double or long contains a value use IntStream, DoubleStream or LongStream respectively.

Example

int[] a = {1,2,3,4};
boolean contains = IntStream.of(a).anyMatch(x -> x == 4);
2 of 16
464

Concise update for Java SE 9

Reference arrays are bad. For this case we are after a set. Since Java SE 9 we have Set.of.

private static final Set<String> VALUES = Set.of(
    "AB","BC","CD","AE"
);

"Given String s, is there a good way of testing whether VALUES contains s?"

VALUES.contains(s)

O(1).

The right type, immutable, O(1) and concise. Beautiful.*

Original answer details

Just to clear the code up to start with. We have (corrected):

public static final String[] VALUES = new String[] {"AB","BC","CD","AE"};

This is a mutable static which FindBugs will tell you is very naughty. Do not modify statics and do not allow other code to do so also. At an absolute minimum, the field should be private:

private static final String[] VALUES = new String[] {"AB","BC","CD","AE"};

(Note, you can actually drop the new String[]; bit.)

Reference arrays are still bad and we want a set:

private static final Set<String> VALUES = new HashSet<String>(Arrays.asList(
     new String[] {"AB","BC","CD","AE"}
));

(Paranoid people, such as myself, may feel more at ease if this was wrapped in Collections.unmodifiableSet - it could then even be made public.)

(*To be a little more on brand, the collections API is predictably still missing immutable collection types and the syntax is still far too verbose, for my tastes.)

🌐
CodeGym
codegym.cc › java blog › java arrays › string array in java
String Array in Java
May 11, 2023 - In other words, arrays in Java are homogeneous. Array cells can contain objects of any type. You can put objects of any type, primitive or object, into an array. Today we are going to look at string arrays in Java language, that is, arrays, each element of which is a string.
Find elsewhere
🌐
Scaler
scaler.com › home › topics › string array in java
String Array in Java - Scaler Topics
April 28, 2024 - The above statement declares a string array of size five where arr is the name of the array and String is the data type for the array. However, you can also write the above declaration as - Both of the above declarations can be used. However, out of the three declarations, the first one is more efficient and is suggested for use. Initialization means to put a value into the variable. However, the data types in Java are, by default, initialized by their default values as soon as they are declared.
🌐
YouTube
youtube.com › watch
Making an Array Of Strings | Java For Beginners - YouTube
Learn how to make an array of strings with java. Sometimes in your java program you will need to store a set of strings together. This tutorial will show you...
Published   February 23, 2016
🌐
Hero Vired
herovired.com › learning-hub › blogs › string-array-in-java
String Array in Java: How to Declare, Example, Initializing
October 7, 2024 - The syntax for declaring and initializing a String Array is very simple. We can declare an array with square brackets and list each piece directly or assign the values from another source, such as a file or database. Also, wrapper class in java provides several methods for working with java string arrays.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Arrays.html
Arrays (Java Platform SE 8 )
October 20, 2025 - A null value indicates that the elements' natural ordering should be used. ... IllegalArgumentException - if fromIndex > toIndex or (optional) if the natural ordering of the array elements is found to violate the Comparable contract · ArrayIndexOutOfBoundsException - if fromIndex < 0 or toIndex > a.length · ClassCastException - if the array contains elements that are not mutually comparable (for example, strings ...
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › arrays.html
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
You can also declare an array of arrays (also known as a multidimensional array) by using two or more sets of brackets, such as String[][] names. Each element, therefore, must be accessed by a corresponding number of index values. In the Java programming language, a multidimensional array is ...
🌐
Quora
quora.com › In-Java-what-is-the-preferred-way-to-create-and-populate-a-String-array
In Java, what is the preferred way to create and populate a String array? - Quora
Answer (1 of 2): Fully depends from where you have it. and what kind of array is just a pure array likes String []? or List , defined as ArrayList (); And that fully depends for what purpose you need. If you want it ordered and later you are going to search all of them by order a lot ...
🌐
Qt Forum
forum.qt.io › home › special interest groups › qtonpi › in java, you may convert a string to an array.
In Java, you may convert a string to an array. | Qt Forum
December 1, 2022 - That's what I see? To actually put the results into an array you would (presumably) need to save the returned result from reverseArray() into a (new) array as you go through the loop. and I expect the result to be an array of strings, but the output is a string.
🌐
Edureka
edureka.co › blog › string-array-in-java
Java String Array | String Array in Java with Examples | Edureka
July 5, 2024 - String Array is used to store a fixed number of Strings. This Java String Array tutorial will help you learn string arrays along with working examples.
🌐
Whitman College
whitman.edu › mathematics › java_tutorial › java › nutsandbolts › arraysAndStrings.html
Arrays and Strings
A sequence of character data is called a string and is implemented in the Java environment by the String class (a member of the java.lang package). The character-counting program uses Strings in two different places. The first is in the definition of the main() method: String[] args This code ...
🌐
freeCodeCamp
freecodecamp.org › news › string-to-array-in-java-how-to-convert-a-string-to-an-array-in-java
String to Array in Java – How to Convert Strings to Arrays
July 6, 2023 - By Shittu Olumide Being able to convert a string into an array can be quite helpful when you're developing text-processing applications or working with data. A string in Java is a group of characters, whereas an array is a collection of the same typ...
🌐
TutorialsPoint
tutorialspoint.com › string-arrays-in-java
String Arrays in Java
May 5, 2023 - The string array is a combination of array and string both. Therefore, it has the properties of both array and string such as ? It stores data in a sequential manner like an array.
🌐
Coderanch
coderanch.com › t › 406173 › java › determine-string-array-string
How can I determine if a string array contains a particular string? (Beginning Java forum at Coderanch)
February 15, 2007 - I suppose I could loop through every element in the array and compare it to the search string but this seems a bit klunky especially when you consider I have four search strings I need to check for. ... Hi, Could you replace the String with a Collection? If so I would use the Set collection and use the functionality of Sets to find if a given string exists in a Set of Strings. Not sure if this is the best solution, or even the neatest, but it is the one I would personally use. Java Trail for Collections You will also find information about HashMap/HashTable collections too.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java string array- tutorial with code examples
Java String Array- Tutorial With Code Examples
April 1, 2025 - We can have an array with strings as its elements. Thus, we can define a String Array as an array holding a fixed number of strings or string values. String array is one structure that is most commonly used in Java.