Université de Sherbrooke
Transcription
Université de Sherbrooke
Conventions pour la représentation graphique des objets en mémoire vive. Variable de type primitif exemple i= 0 int i = 0; Variable de type référence : p1 = Personne Personne p1 = new Personne("Paul"); Vecteur de type primitif nom = conjoint = null noPersonne = 1 v= int[] v = new int[3]; v[0] = 4; v[1] = 5; v[2] = 6; Vecteur d'objets v= String[] v = new String[2]; v[0] = "ab"; v[1] = "cd"; Collection d'Objets Map<Integer,String> s = new HashMap<Integer,String>(); m.put(1,"ab"); m.put(3,"cd"); Class C { int i; String s; C(int i, String s) {this.i=i; this.s=s} } String s = "ab"; C c1 = new C(1,s); 0 1 String “cd” String “ab” String “cd” String “ab” String “cd” 0 l= 1 String “ab” String “cd” m= Integer 1 Integer 3 Classe avec attributs 6 s= List<String> l = new LinkedList<String>(); l.add("ab"); l.add("cd"); Map d'Objets 2 5 Paul b= Set<String> s = new HashSet<String>(); s.add("ab"); s.add("cd"); s.add("ab"); List d'objets 1 4 String “ab” Collection<String> b = new OSHashBag<String>(); b.add("ab"); b.add("cd"); b.add("ab"); Set d'Objets 0 String String “ab” v k c1 = C i= s= String “cd” 1 s= String “ab” 1 de 1