Arieccomi con un nuovo test.
Dovrei creare delle classi che validano questo test.codice:import java.util.*; public class TestSheet { public static void main(String[] args) { Spreadsheet spreadsheet = new SimpleSpreadsheet(); List<WorkSheet> list = spreadsheet; // this should be respected assert (list.get(0) instanceof Map<Coordinates,Object>); assert spreadsheet.size() == 1; spreadsheet.get(0).put(new Coordinates("A1"), new Integer(5)); }
Ho creato dunque:
compilando mi da un errorecodice:public class SimpleSpreadsheet extends Spreadsheet{ public SimpleSpreadsheet(){ super(); } } public class Spreadsheet extends ArrayList<WorkSheet>{ public Spreadsheet(){ this.add(new WorkSheet("A0", 0)); } } public class WorkSheet<K,V> extends HashMap<K,V>{ public WorkSheet(){ super(0); } } public class Coordinates{ String coord; public Coordinates(String coord){ this.coord = coord; } }sulla rigacodice:illegal generic type for instanceof
Qualche consiglio?codice:assert (list.get(0) instanceof Map<Coordinates,Object>);

Rispondi quotando
