Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
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++){
    System.out.println(roseindia[i]);
    }
  }
}

Output of program:

C:\>javac StringCharacter.java

C:\>java StringCharacter
chanan
tapan
Amar
santosh
deepak

C:\>

Download this Example.

                         

» View all related tutorials
Related Tags: c file array class list ui lists method get name using this oo root example where to exam drive store

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

5 comments so far (
post your own) View All Comments Latest 10 Comments:

how can i make a program that ask the user to input integers, then evaluate it and say whether the array is a series of two or more adjacent elements of the same value....

example:
input : 1 1 2 2 3
output: 2

tnx...

Posted by ree on Sunday, 11.30.08 @ 05:58am | #82194

hi,
how can i declare sentence "remove this" as array,then read array[0]=remove and array[1]=this

Posted by dee on Wednesday, 12.12.07 @ 16:30pm | #41944

Sir,
Can U Give Me An Example on Dynamically Initalizing The Arrays i.e., By Reading Using System.in.read()

Posted by Praneeth Kumar on Wednesday, 12.5.07 @ 10:49am | #41332

Hi Anand,

Thanks for your comments. We have just tested the application and found the output in the following format:

C:\>java StringCharacter
chanan
tapan
Amar
santosh
deepak

You are right the values in the array will be printed in the sequence it was added.

Thanks for your comment.

Posted by Deepak Kumar on Monday, 05.21.07 @ 18:06pm | #16920

class StringCharacter
{
static String[] roseindia={"chanan","tapan","Amar","santosh","deepak"};
public static void main(String args[]){
for(int i=0;i<5;i++){
System.out.println(roseindia[i]);
}
}
}
Output of program:

C:\amar work>javac StringCharacter.java

C:\amar work>java StringCharacter
chandan
Amar
tapan
santosh
deepak

C:\amar work>
My question: Now i want to know that how amar has been chosen between them for treatment?

Posted by Anand Kumar Singh on Monday, 05.21.07 @ 17:22pm | #16918

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.