2017-03-07 27 views

答えて

1

このようにすることができます。

interface FruitInterface { /* common methods */ } 
public class Apple implements FruitInterface { } 
public class Pear implements FruitInterface { } 

SparseArray<FruitInterface> fruits = new SparseArray<FruitInterface>(); 

または、このようにすることができます。

SparseArray<Object> fruits = new SparseArray<Object>(); 

、その後、私はあなたが `SparseArray`を意味すると仮定し

if (fruits.get(0) instanceof Apple) { 
} else if (fruits.get(0) instanceof Pear) { 
} 
関連する問題