
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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"}
Advertisements