adsense


Showing posts with label JAVA EXAMPLES ARRAY OUTPUT. Show all posts
Showing posts with label JAVA EXAMPLES ARRAY OUTPUT. Show all posts

Saturday, 24 October 2015

JAVA EXAMPLES ARRAY OUTPUT PAGE 48

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES ARRAY OUTPUT



Java Examples - Array output


Problem Description:
How to write an array of strings to the output console ?
Solution:
Following example demonstrates writing elements of an array to the output console through looping.
public class Welcome {
   public static void main(String[] args){
      String[] greeting = new String[3];
      greeting[0] = "This is the greeting";
      greeting[1] = "for all the readers from";
      greeting[2] = "Java Source .";
      for (int i = 0; i < greeting.length; i++){
         System.out.println(greeting[i]);
      }
   }
}
Result:
The above code sample will produce the following result.
This is the greeting
For all the readers From
Java source .