Where is the Array's "length" attribute defined in?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   neal_ravindran
Posted On:   Tuesday, January 22, 2002 05:36 AM

When we have an array and want to find its length we do "arrayname.length"

But in which package is that defined? I read somewhere(nutshell book?) that the
Array class 'can be considered to be derived from Object class'. But I did not find
a "length" attribute in Object class either.(I am not talking about the new java.util.Array class
here, but our Array since java 1.0)

Re: Where is the Array's "length" attribute defined in?

Posted By:   ramakanth_vaidhyula  
Posted On:   Tuesday, January 22, 2002 06:39 AM

Array length can be found using length method


ex:


public class ArrayLength{


public static void main(String c[])

{


try


{


String a[] = {"a","b"};


System.out.println("length of array" + a.length);


}


catch(Exception ex)


{


System.out.println("Unable to Find Length" +ex);


}


}


}
About | Sitemap | Contact