What's the Kotlin equivalent of Java's String?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
This question usually means “What is the Kotlin equivalent of Java’s String[]?” In Kotlin, the direct equivalent is Array<String>, and in many cases you create it with arrayOf(...).
Java String[] vs Kotlin Array<String>
In Java, a string array looks like this:
In Kotlin, the equivalent looks like this:
That is the core mapping:
- Java
String[] - Kotlin
Array<String>
The two are conceptually the same kind of structure: a fixed-size array containing string elements.
The Most Common Kotlin Forms
The most common way to create a string array in Kotlin is arrayOf(...).
You can also declare the type explicitly:
Or create an array by size:
This creates a fixed-size array with three string elements initialized through the lambda.
Access and Mutation Work the Same Way
Array indexing feels very similar to Java:
So if you are moving from Java to Kotlin, the main change is the type syntax, not the basic array behavior.
The size remains fixed, just like a Java array. If you need a collection that grows and shrinks, you probably want a list rather than an array.
Arrays vs Lists in Kotlin
This is where Kotlin differs more in style than in capability. Kotlin code often prefers List<String> over Array<String> unless a real array is needed.
For example:
Why does this matter?
Because in Kotlin:
- arrays are fixed-size indexed containers
- lists are the more common high-level collection type
So if you are translating Java literally, String[] becomes Array<String>. But if you are writing idiomatic Kotlin from scratch, List<String> is often the more natural choice.
Interoperability With Java
Kotlin interoperates smoothly with Java arrays. If a Java method expects String[], Kotlin can pass Array<String> naturally in many cases.
This is one reason the Array<String> type exists so directly. Kotlin needs a clear representation that maps cleanly to Java arrays.
Nullability Matters
Kotlin also makes nullability explicit, which is something Java arrays do not express in the type system as clearly.
An array of non-null strings:
An array where elements may be null:
This is an important Kotlin advantage. The type tells you whether null elements are allowed.
Varargs and Command-Line Arguments
One place Java developers often see string arrays in Kotlin is main:
That is the Kotlin equivalent of Java’s public static void main(String[] args).
So even though Kotlin often prefers lists in application code, arrays are still normal and important in interop and entry-point scenarios.
Common Pitfalls
The most common pitfall is translating Java String[] mechanically without asking whether Kotlin List<String> would actually be the better choice for the new code.
Another mistake is forgetting the type syntax and writing Java-style array declarations in Kotlin. Kotlin uses Array<String>, not String[] in type declarations.
A third issue is overlooking nullability. Array<String> and Array<String?> are different types with different guarantees.
Finally, some developers assume Kotlin arrays are dynamically resizable because the language has rich collection APIs. They are not. Arrays stay fixed-size.
Summary
- The Kotlin equivalent of Java
String[]isArray<String>. - The most common creation syntax is
arrayOf("a", "b", "c"). - Arrays in Kotlin are fixed-size, just like Java arrays.
- In idiomatic Kotlin,
List<String>is often preferred when array behavior is not required. - Kotlin makes string-array nullability explicit through types such as
Array<String?>.

