String Array Object String Array

String Array Object String Array

String Array Object String Array

Summary: By the end of this tutorial "String Array Object String Array", you will come to know how to create string array and converting object array to string array.

String arrays play very important role in any language coding. In the following program, string arrays are created in three ways.

1. Declaration and assignment
2. Initialization
3. Object array to string array


String Array Object String Array
Output screen of StringArrays of String Array Object String Array

It is a special type of for loop known as enhanced for loop, introduced with JDK 1.5 to iterate string and datastructure elements.

An object array obj containing some string elements is created and in the for loop each object element is type casted to string element.

Array related topics that increase array manipulation techniques

Topics related to In and Outs of interfaces

5 thoughts on “String Array Object String Array

  1. p.pavan

    public class Demo1
    {
    public static void main(String[] args)
    {
    Object obj[] = { 65,66,67,68,69};
    int sarray3[] = new int[obj.length];
    System.out.println(sarray3.length);
    for(int i=0;i<sarray3.length;i++)
    {
    sarray3[i]=(int) obj[i];
    System.out.println(sarray3[i]);
    }
    }
    }
    Sir can i print like this?

    1. S. Nageswara Rao, Corporate Trainer Post author

      First of all this statement is wrong?

      Object obj[] = { 65,66,67,68,69};

      How an int can be an object.

      Do it like this:

      public class Demo
      {
      public static void main(String[] args)
      {
      // Object obj[] = { 65,66,67,68,69};

      Object obj[] = { new Integer(65),new Integer(66),new Integer(67),new Integer(68),new Integer(69)};

      int sarray3[] = new int[obj.length];
      System.out.println(sarray3.length);
      for(int i=0;i

  2. p.pavan

    Sir can i create the array of integer in the above program??
    Object obj[] = { “avoid”, “gizmos”, “carrying”, “to”, “workstation” };
    int sarray3[] = new int[obj.length];
    is it possible??

Leave a Reply

Your email address will not be published. Required fields are marked *