我有這樣的代碼,我喜歡對象之前創建前:我該如何檢查兩個向量之間的第一個對象?
client[0],youngClient[1],client[2],youngClient[3]...
和調用此方法我用: int result = freeObject("client","youngClient");
這是代碼....
private static int freeObject(String objectName1, String objectName2){
int i=0, solucion=0;
boolean salir = false;
do{
String objectFull1 = objectName1 + "[" + i + "]";
String objectFull2 = objectName2 + "[" + i + "]";
if(objectFull1.equals(null) && objectFull2.equals(null)){
solucion = i;
salir = true;
}
i++;
}while(!salir);
return solucion;
}