What's the Kotlin equivalent of Java's String?
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
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?>.
Related reading
- What's the name of this array data structure?
- What's the purpose of BFS and DFS?
- What's the reason I can't create generic array types in Java?
- What's the simplest algorithm/solution for a single pair shortest path through a real-weighted undirected graph?
- What's the meaning of an object's monitor in Java? Why use this word?
- What's the nearest substitute for a function pointer in Java?
- What''s the point of NSAssert, actually?
- what's the purpose of double question mark in swift

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.