Menu
Topics Index
...
`

String Arrays Demo - Java Example Program


String Arrays Demo
class StringArrayDemo
{
    public static void main(String[] args)
    {
        String names[] = {"Prem", "Siva", "Mahesh", "Srinath"};
        for(int i =0; i < names.length; i++)
        {
            System.out.println(names[i]);
        }
    }
}
OUTPUT

Prem
Siva
Mahesh
Srinath

DESCRIPTION

In the above program we declared a String array with elements and printed the elements in the array using a forward for loop.

THINGS TO TRY
  • Declare a String array with size of 4 and add elements to it.
  • Print the element in the names array in reverse order. Use reverse for loop.

© meritcampus 2019

All Rights Reserved.

Open In App