- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create array of strings in Java?
In Java, you can create an array just like an object using the new keyword. The syntax of creating an array in Java using new keyword −
type[] reference = new type[10];
Where,
type is the data type of the elements of the array.
reference is the reference that holds the array.
And, if you want to populate the array by assigning values to all the elements one by one using the index −
reference [0] = value1; reference [1] = value2;
You can declare an array of Strings using the new keyword as &mius;
String[] str = new String[5];
And then, you can populate the string using the indices as −
str[0] = "JavaFX"; str[1] = "OpenCV"; str[2] = "ApacheFlume"; str[3] = "Apache Hadoop"; str[4] = "WebGL";
You can also create a String array directly using the curly braces as −
String str = str[0] = {"JavaFX", "OpenCV", "ApacheFlume", "Apache Hadoop", "WebGL"}
- Related Articles
- How to create an array of strings in JavaScript?
- Java Program to Create random strings
- How to create an array of Object in Java
- How to create an Array in Java?
- How to convert array of decimal strings to array of integer strings without decimal in JavaScript
- How to create an array of linked lists in java?
- How to create a generic array in java?
- How to convert array of strings to array of numbers in JavaScript?
- How convert an array of Strings in a single String in java?
- How to create a dynamic 2D array in Java?
- How to create and populate Java array of Hash tables?
- How to sort array of strings by their lengths following longest to shortest pattern in Java
- How to sort array of strings by their lengths following shortest to longest pattern in Java
- Java Program to write an array of strings to a file
- How to convert array of comma separated strings to array of objects?

Advertisements