The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java Tutorial : Java Array (String values)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ram N

Posts: 2777
Nickname: ramram
Registered: Jul, 2014

Ram N is Java Programmer
Java Tutorial : Java Array (String values) Posted: Oct 23, 2015 9:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ram N.
Original Post: Java Tutorial : Java Array (String values)
Feed Title: JAVA EE
Feed URL: http://ramj2ee.blogspot.com/feeds/posts/default?alt=rss
Feed Description: This blog has viedo tutorials and Sample codes related to below Technologies. 1.J2EE 2.Java 3.Spring 4.Hibernate 5.Database 6.Oracle 7.Mysql 8.Design Patterns
Latest Java Buzz Posts
Latest Java Buzz Posts by Ram N
Latest Posts From JAVA EE

Advertisement

Click here to watch in Youtube :
https://www.youtube.com/watch?v=rsH5b2ZODHY&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Array (String values) 
ArrayDemo.java
class ArrayDemo
{
public static void main(String[] args)
{
// declares an array of Strings and allocates memory for 10 Strings
String[] strArray = new String[10];

// initialize first element
strArray[0] = "Apple";
// initialize second element
strArray[1] = "Ball";
// and so forth
strArray[2] = "Car";
strArray[3] = "Dog";
strArray[4] = "Eagle";
strArray[5] = "Fox";
strArray[6] = "Girl";
strArray[7] = "Horse";
strArray[8] = "Ink";
strArray[9] = "Jack";

System.out.println("Element at index 0: " + strArray[0]);
System.out.println("Element at index 1: " + strArray[1]);
System.out.println("Element at index 2: " + strArray[2]);
System.out.println("Element at index 3: " + strArray[3]);
System.out.println("Element at index 4: " + strArray[4]);
System.out.println("Element at index 5: " + strArray[5]);
System.out.println("Element at index 6: " + strArray[6]);
System.out.println("Element at index 7: " + strArray[7]);
System.out.println("Element at index 8: " + strArray[8]);
System.out.println("Element at index 9: " + strArray[9]);

}
}
Output
Element at index 0: Apple
Element at index 1: Ball
Element at index 2: Car
Element at index 3: Dog
Element at index 4: Eagle
Element at index 5: Fox
Element at index 6: Girl
Element at index 7: Horse
Element at index 8: Ink
Element at index 9: Jack
ArrayLoopDemo.java
class ArrayLoopDemo
{
public static void main(String[] args)
{
// declares an array of Strings and allocates memory for 10 Strings
String[] strArray = new String[10];

// initialize first element
strArray[0] = "Apple";
// initialize second element
strArray[1] = "Ball";
// and so forth
strArray[2] = "Car";
strArray[3] = "Dog";
strArray[4] = "Eagle";
strArray[5] = "Fox";
strArray[6] = "Girl";
strArray[7] = "Horse";
strArray[8] = "Ink";
strArray[9] = "Jack";

System.out.println("Using For-each loop getting each element from the String Array\n");

/*
* Using For-each loop get all elements from strArray
*/

int i=0;
for (String value : strArray)
{
System.out.println("Element at index " +i+" : "+ value);
++i;
}
}
}
Output
Using For-each loop getting each element from the String Array

Element at index 0 : Apple
Element at index 1 : Ball
Element at index 2 : Car
Element at index 3 : Dog
Element at index 4 : Eagle
Element at index 5 : Fox
Element at index 6 : Girl
Element at index 7 : Horse
Element at index 8 : Ink
Element at index 9 : Jack
To Download ArrayDemoStringApp Project Click the below link
https://sites.google.com/site/javaee4321/java/ArrayDemoStringApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Read: Java Tutorial : Java Array (String values)

    Topic: jOOQ Tuesdays: Markus Winand is on a Modern SQL Mission Previous Topic   Next Topic Topic: BaDaS Arsenal : from grep to graph in under 5 minutes w/ Pyplot

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use