书上使用了数组的length成员,还有clone方法,都是直接在数组名后面使用的,比如
int a[]=new int[10];
int[] b=a.clone();有的时候又是用Array类的静态方法操纵数组。不知道两者有何区别?在哪里能看到数组类的成员和方法?

解决方案 »

  1.   

    int[] array = new int[10];
    Class clazz = array.getClass();
    System.out.println(clazz);
    Method[] methods = clazz.getDeclaredMethods();
    System.out.println(methods.length);
    for(Method m : methods){
        System.out.println(m.getName());
    } Method[] methodz = clazz.getMethods();
    System.out.println(methodz.length);
    for(Method m : methodz){
        System.out.println(m.getName());
    }

    Class superclass = clazz.getSuperclass();
    System.out.println(superclass.getName()); Class[] interfaces = clazz.getInterfaces();
    for(Class i : interfaces){
        System.out.println(i.getName());
    }
      

  2.   

    数组不是类,但是实现了Object中的方法
    按照Java语言规范的说法:Java数据类型分为两大类:基本数据类型和复合数据类型,其中复合数据类型包括数组、类和接口。
      

  3.   

    public class Test {
    public static void main(String[] args) {
    Name[] n = new Name[10];
    int[] a = new int[10];

    //打印类名
    //[I
    //[LName;
    System.out.println(a.getClass().getName());
    System.out.println(n.getClass().getName());

    //判断是否为Object或者其子类
    //true
    //true
    System.out.println(a instanceof Object);
    System.out.println(n instanceof Object);

    //从打印结果看,数组就是类,是Object的子类,只是他比较特殊,语言层面上没有提供 //具体的类名等,在编译期间特殊处理的
    }
    }class Name {

    }具体的查找他属性和方法等,可以用反射,2楼的说清楚了!
      

  4.   

    Array这一个帮助类。专门来操作数组的帮助类。
      

  5.   

    还在讨论这个问题;THE Java programming language is a strongly typed language, which means
    that every variable and every expression has a type that is known at compile time.
    Types limit the values that a variable (§4.12) can hold or that an expression can
    produce, limit the operations supported on those values, and determine the meaning
    of the operations. Strong typing helps detect errors at compile time.
    The types of the Java programming language are divided into two categories:
    primitive types and reference types. The primitive types (§4.2) are the boolean
    type and the numeric types. The numeric types are the integral types byte, short,
    int, long, and char, and the floating-point types float and double. The reference
    types (§4.3) are class types, interface types, and array types. There is also a
    special null type. An object (§4.3.1) is a dynamically created instance of a class
    type or a dynamically created array. The values of a reference type are references
    to objects. All objects, including arrays, support the methods of class Object
    (§4.3.2). String literals are represented by String objects (§4.3.3).
      

  6.   

    数组的 length 属性和 clone() 实现都是由 Java 编译器自动给加上的。