El primer índice se establece en nulo (vacío), pero no imprime el resultado correcto, ¿por qué?¿Por qué el trabajo list.get (0) .equals (null) no funciona?
//set the first index as null and the rest as "High"
String a []= {null,"High","High","High","High","High"};
//add array to arraylist
ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a));
for(int i=0; i<choice.size(); i++){
if(i==0){
if(choice.get(0).equals(null))
System.out.println("I am empty"); //it doesn't print this output
}
}
Un truco: 'System.out.println (Arrays.asList (nulo," Alto "," Alto "," Alto "," Alto "," Alto "));' Hace lo que quiere sin todo eso código extra Digo que es el "mismo" porque probablemente no sabía que podía imprimir nulos – Pyrolistical