Monday, March 16, 2015

strings to the output console in java pgm



To write an array of strings to the output console
 
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:

This is the greeting
For all the readers From
Java source .

No comments:

Post a Comment