You need to initialize errorSoon, as indicated by the error message, you have only declared it.

Use with AIString[] errorSoon;                   // <--declared statement
String[] errorSoon = new String[100]; // <--initialized statement

You need to initialize the array so it can allocate the correct memory storage for the String elements before you can start setting the index.

If you only declare the array (as you did) there is no memory allocated for the String elements, but only a reference handle to errorSoon, and will throw an error when you try to initialize a variable at any index.

As a side note, you could also initialize the String array inside braces, { } as so,

Use with AIString[] errorSoon = {"Hello", "World"};

which is equivalent to

Use with AIString[] errorSoon = new String[2];
errorSoon[0] = "Hello";
errorSoon[1] = "World";
Answer from Anthony Forloney on Stack Overflow
🌐
Techie Delight
techiedelight.com › home › java › initialize an array of string in java
Initialize an array of String in Java | Techie Delight
July 7, 2026 - 1. We can declare and initialize an array of string in Java by using a new operator with an array initializer. For example, the following code snippet creates an array of string of size 5:
Discussions

How to create and initialise in Java an array of String arrays in one line? - Stack Overflow
Use with AICopyString[][] array = new String[][] {emptyArr, filledArr, moreFilledArr}; please do check these too Docs for Array in Java Have a Look for more clarification tutorial of array with java docs , I had to add this as a comment but I couldn't, I want to extend with more resources mentioned above , Thanks ... Save this answer. ... Show activity on this post. We can also achieve it by initialising ... More on stackoverflow.com
🌐 stackoverflow.com
In Java, how do I initialize an array of strings? - Stack Overflow
If I set String[] Year = null, then I can initialize the string. HOWEVER, if I do that, an exception is thrown when attempting to run & compile the code: java.lang.NullPointerException · I know that my code could be shorter, but I am trying to isolate the problem... ... Save this answer. ... Show activity on this post. ... Now Java knows how long you want the array ... More on stackoverflow.com
🌐 stackoverflow.com
Java - How do I make a String array with values? - Stack Overflow
This is more usefull for initializing (possibly large) arrays where you can compute each element from its index. ... Save this answer. ... Show activity on this post. Another way to create an array with String apart from · String[] strings = { "abc", "def", "hij", "xyz" }; is to use split. I find this more readable if there are lots of ... More on stackoverflow.com
🌐 stackoverflow.com
How do I initialize a Java String array when doing java interop
(into-array String ["one" "two"]) More on reddit.com
🌐 r/Clojure
3
5
January 28, 2022
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array
Java String Array: Declaration, Initialization & Examples | DigitalOcean
August 3, 2022 - Master Java String arrays with declaration, initialization, and manipulation examples. Learn iteration, sorting, searching, and conversion techniques.
🌐
GeeksforGeeks
geeksforgeeks.org › java › string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - // Java program to demonstrate the // conversion of String array to String public class GFG { public static void main(String[] args) { // Initialize a String array with some elements String[] arr = { "She", "is", "a", "good", "girl" }; // Create ...
🌐
TutorialKart
tutorialkart.com › java › how-to-initialize-string-array-in-java
How to Initialize String Array in Java?
January 12, 2021 - ... public class Example { public static void main(String[] args){ String fruits[] = new String[4]; fruits[0] = "apple"; fruits[1] = "banana"; fruits[2] = "mango"; fruits[3] = "orange"; for(String fruit: fruits) { System.out.println(fruit); ...
Find elsewhere
🌐
javaspring
javaspring.net › blog › java-initialize-array-of-string
Java Initialize Array of String: A Comprehensive Guide — javaspring.net
When an array of strings is initialized, Java allocates a contiguous block of memory to store references to the string objects.
🌐
freeCodeCamp
freecodecamp.org › news › java-array-how-to-declare-and-initialize-an-array-in-java-example
Java Array – How to Declare and Initialize an Array in Java Example
February 4, 2022 - String[] names = {"John", "Jade", "Love", "Allen"}; ... We have initialized our arrays by passing in values with the same data type with each value separated by a comma. If we wanted to access the elements/values in our array, we would refer ...
🌐
Delft Stack
delftstack.com › home › howto › java › how to initialize a string array in java
How to Initialize a String Array in Java | Delft Stack
March 13, 2025 - ... In this example, we declare a String array called fruits and initialize it with three values: “Apple,” “Banana,” and “Cherry.” This method is particularly useful when you know the values you want to store in advance.
🌐
CodeGym
codegym.cc › java blog › java arrays › string array in java
String Array in Java
May 11, 2023 - Today we are going to look at string arrays in Java language, that is, arrays, each element of which is a string. We'll figure out how to declare Java String Array and how to work with it. You can declare and initialize a String array in Java in different ways. For example like in code below:
🌐
TutorialKart
tutorialkart.com › java › java-array › java-string-array
Java String Array - Examples
November 23, 2020 - Following is the syntax to declare an Array of Strings in Java. ... You can use any of these two notations. To initialize a string array, you can assign the array variable with new string array of specific size as shown below.
🌐
Codemia
codemia.io › home › knowledge hub › java how to initialize string[]?
Java how to initialize String[]? | Codemia
January 27, 2025 - There are multiple ways to initialize a String[] in Java: At declaration: This method involves directly specifying the elements of the array at the time of its declaration.
🌐
Quicktakes
quicktakes.io › learn › computer-science › questions › how-do-you-declare-and-initialize-a-string-array-in-java
Student Question : How do you declare and initialize a string array in Java? | Computer Science | QuickTakes
Here is a complete example demonstrating both declaration and initialization: public class StringArrayExample { public static void main(String[] args) { // Declaration and initialization at the same time String[] fruits = new String[5]; // Array of size 5 // Populating the array fruits[0] = ...
🌐
W3docs
w3docs.com › home › code snippets › java › java: how to initialize string[]?
Java: how to initialize String[]? | W3docs
Here are a few examples: // method 1: using an array literal String[] arr1 = {"apple", "banana", "cherry"}; // method 2: using the new operator String[] arr2 = new String[] {"apple", "banana", "cherry"}; // method 3: using the new operator and ...
🌐
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.
🌐
DataCamp
datacamp.com › doc › java › defining-and-initializing-arrays
Java Defining and Initializing Arrays
You can initialize an array at the time of declaration using curly braces {} with the values separated by commas. dataType[] arrayName = {value1, value2, ..., valueN}; Powered by · int[] numbers = {1, 2, 3, 4, 5}; String[] names = {"Alice", "Bob", "Charlie"}; Powered by · In this example, ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-declare-and-initialize-an-array-in-java
How to Declare and Initialize an Array in Java - GeeksforGeeks
October 11, 2025 - int[] numbers = {10, 20, 30, 40, 50}; String[] fruits = {"Apple", "Banana", "Mango"}; The array is created first with a specific size, and values are assigned later. int[] numbers = new int[5]; // Array of size 5 numbers[0] = 10; numbers[1] ...