2016-01-23 70 views

回答

1

你的阵列应该是一个实例变量:

public class Example { 

    // Private variables defined outside of a method/constructor can 
    // be used anywhere within the class but not outside of the class 
    private String[] array; 

    public Example() { 
     array = new String[6]; 
    } 

    public int length() { 
     return array.length; 
    } 
} 
相关问题