java.lang.Class.isArray()


java.lang.Class.isArray()

package com.codingdict;



import java.lang.*;



public class ClassDemo {



   public static void main(String[] args) {



      String str = "This is codingdict";



      // returns true if this object represents an array class, else false

      Class cls = str.getClass();



      // checking for array

      boolean arr = cls.isArray();

      if(arr) {

         System.out.println("Result : " + cls.getName() + " is an array");

      } else {

         System.out.println("Result : " + cls.getName() + " is not an array");

      }

   }

}