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
🌐
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.
Discussions

How to create and initialise in Java an array of String arrays in one line? - Stack Overflow
please do check these too Docs ... 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 ... We can also achieve it by initialising and assigning to a single dimensional array of type Object. Something like below. String[] filledArr ... More on stackoverflow.com
🌐 stackoverflow.com
How can I initialize a String array with length 0 in Java? - Stack Overflow
It's clearer to me that it means "I want a string array with 0 elements" rather than "I want an array with this content - which is empty". Just personal preference I guess. 2009-11-03T08:40:19.48Z+00:00 ... @Tony - I have to use the few places where Java can infer a type. More on stackoverflow.com
🌐 stackoverflow.com
Java - How do I make a String array with values? - Stack Overflow
I know how to make an empty array, but how do I make a String array with values from the start? More on stackoverflow.com
🌐 stackoverflow.com
Initialization of a static array c to rust
Hello I want to express the following C code in rust. C Code static unsigned char CONFIG[2000] = "some type of config string"; The rest of the array… More on reddit.com
🌐 r/rust
19
6
July 13, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › java › string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - In this method, we are declaring the values at the same line. String[] arr0 = new String[]{"Apple", "Banana", "Orange"}; This method is the short form of the first method i.e. initialize the array at the time of declaration.
🌐
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.
🌐
TutorialKart
tutorialkart.com › java › how-to-initialize-string-array-in-java
How to Initialize String Array in Java?
January 12, 2021 - To initialize String Array in Java, define a string array and assign a set of elements to the array, or define a string array with specific size and assign values to the array using index.
🌐
Baeldung
baeldung.com › home › java › java array › initializing arrays in java
Initializing Arrays in Java | Baeldung
December 16, 2024 - When we declare an array, knowing the size is unnecessary. We can either assign an array to null or an empty array: ... But we need to know the size when we initialize it because the Java virtual machine must reserve the contiguous memory block for it.
Find elsewhere
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java string array- tutorial with code examples
Java String Array- Tutorial With Code Examples
April 1, 2025 - This tutorial on Java String Array explains how to declare, initialize & create String Arrays in Java and conversions that we can carry out on String Array.
🌐
CodeGym
codegym.cc › java blog › java arrays › string array in java
String Array in Java
May 11, 2023 - However Java has special tricks for it. If you’ve got an array of strings and need to add a new string to the end of your array, use the Arrays.copyOf method. This method creates a new array with one extra element, and then adds the new element to the end of the new array.
🌐
Hero Vired
herovired.com › learning-hub › blogs › string-array-in-java
String Array in Java: How to Declare, Example, Initializing
October 7, 2024 - Understanding how to work with ... and initialize a String Array in Java using the following syntax: "`Java String[] myArray = {"one", "two", "three"}; ```...
🌐
Sentry
sentry.io › sentry answers › java › how to initialize an array in one line in java
Java Initialize an Array in One Line with Examples | Sentry
September 17, 2026 - public class Main { public static void main(String[] args) { String[] words = new String[4]; words[0] = "java"; words[1] = "arrays"; words[2] = "are"; words[3] = "easy"; System.out.println(words[0]); System.out.println(words[1]); } } However, sometimes you have all the data you need when you initialize the array, and you want to initialize the array using less code.
🌐
W3docs
w3docs.com › home › code snippets › java › java: how to initialize string[]?
Java: how to initialize String[]? | W3docs
// 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 specifying the size of ...
🌐
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.
🌐
HappyCoders
happycoders.eu › home › java › how to declare and initialize arrays in java
How to Declare and Initialize Arrays in Java
September 24, 2026 - We do not yet specify the size of the array in the declaration. The array variables (in the example intArray and stringArray) do not contain the array itself but a reference to an array, which is ultimately an object on the Java heap. Only when we create the array object itself do we have to define its size.
🌐
DataCamp
datacamp.com › doc › java › defining-and-initializing-arrays
Java Defining and Initializing Arrays
In this example, the numbers array is initialized with integers, and the names array is initialized with strings.
🌐
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 - 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 to their index number in the array.
🌐
Career Karma
careerkarma.com › blog › java › java initialize array: a step-by-step guide
Java Initialize Array: A Step-By-Step Guide | Career Karma
December 1, 2023 - Then we use the new String[10] ... has been defined, it cannot be changed. Initializing an array refers to the process of assigning values to an array....
🌐
Unstop
unstop.com › home › blog › string array in java | create, operations & more (+examples)
String Array In Java | Create, Operations & More (+Examples)
January 15, 2025 - Output (set code file name as StringArrayIteration.java): Using traditional for loop: Cat Dog Elephant Lion Tiger · Using enhanced for loop: Cat Dog Elephant Lion Tiger ... We begin by declaring a class named StringArrayIteration with a main method, which is the starting point of the program. We declare and initialize a String array named animals, containing the elements "Cat," "Dog," "Elephant," "Lion," and "Tiger."