我正在尝试创建一个布尔方法来调整我的数组大小,如果扩大则返回 true,否则返回 false 缩小!这是我到目前为止所做的,请帮助我,我不知道剩下的事情是什么:)
public class StringArray implements InterfaceStringArray{
String[] strArray; // create an array & store value
private int nElems =0; // number of elements
final int ARRAY_MAX = 100;
StringArray bubbleSort= new StringArray(); // create bubbleSort object
StringArray selectSort = new StringArray(); // create selectSort object
StringArray insertSort = new StringArray(); // create insertSort object
public void initialize (int arrSize) { //initializes an array of size=arrSize
strArray = new String [arrSize];
}
public int getSize() { //returns the current array size
return strArray.length;
}
public boolean resize(int newSize) { //returns true if successful (widening), false if narrowing
String[] newArray = new String[ strArray.length * 2];
for ( int x=0; x < strArray.length; x++){ // Load array
if (newArray[x].equals(strArray[x]) )
return true;
}
return false;
}