String Array In Java

In this section, you will learn how to use string array in Java.

String Array In Java


In this section, you will learn how to use string array in Java. Here, you will see how to declare a string array and the syntax for using in the program. This section provides you a simple java program which illustrates about the string array in very efficient manner.

Program Description:

Following code of the program declares a string array and store some strings like "chandan", "tapan", "Amar", "santosh", and "deepak" to it. And in the main method these string are displayed one by one by retrieving from the specified string array named roseindia. In this program all the string values are stored in the roseindia string array at the declaration time.

Here is the code of this program:

class StringCharacter 
  static String[] roseindia={"chanan","tapan","Amar","santosh","deepak"};
  public static void main(String args[]){
  for(int i=0;i<5;i++){

Output of program:


C:\>java StringCharacter


Download this Example.

Share on Google+Share on Google+

String Array In Java

Posted on: June 5, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: String Array In Java   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
November 11, 2011

store and retrive values in java without using to create
roshni sanhaliya
November 30, 2011
java proamming

thank u
January 10, 2012
datastructure lab

i can't understand!
January 10, 2012
datastructure lab

i can't understand
Ashok Naik
February 17, 2012

1)how to count number of strings repeated in a string array? 2)i want to display the output like Naik Ashok instead of Ashok Naik ...what is the logic of this program?
March 11, 2012
Switch String in Java

How to use string in switch statement in Java.
March 11, 2012
Switch Statement using String

How to use Switch statement in Java using String. switch(String s){...}. This is the not working. Please could I get exactly how should be written. Any one please help me.
roy charman
December 9, 2012
string arrays

For one of my college assignments I have to enter a string (ones that's already been declared) (the name of a song artist) then for I need the program to out put the string location (the chart rating of the aritist) how can I do this? I'm quite stuck
Bhim prasad sharma
October 3, 2013

package Practise; import java.util.*; import java.util.Scanner; public class testShape { static Scanner console=new Scanner(; public static void main(String[]args) { Circle c=new Circle(); Square s=new Square(); Rectangle r=new Rectangle(); Triangle t=new Triangle(); int input=0; double radius=0; System.out.println("This program will compute the area of Circle, Triangle, Square and Rectangle.\n"); System.out.println("You are required to enter input and kindly follow the direction. \n "); System.out.println("Just choose below what area do you want to know.\n "); System.out.println("circle, triangle, rectangle, square: \n"); String; /*System.out.println("\nEnter for a loop number: "); input=console.nextInt(); String[] choice=new String[input]; for(int i=0; i<choice.length;i++){ System.out.println("circle, triangle, rectangle, square \n input: "); choice[i]; */ if (choice.equals("circle")){ System.out.println("Please Enter the radius, area, diameter"); String; c.setGiven(givenType); c.condition(givenType, radius, radius, radius); } else if(choice.equals("triangle")) { t.computeTriangle(radius, radius); } else if(choice.equals("rectangle")){ r.computeRectangle(radius, radius); } else if(choice.equals("square")){ System.out.println("This program will compute for the Area of a squre"); s.computeSquare(radius); } else System.out.println("your input is not in the choices given!"); } }