/* Declaration de tableaux de variables */ /* de type agrege position en deux dimensions */ public class TableauPosition2Dv2 { /* Type agrege de stockage d'une position du plan */ static class Position2D { double x = 0.0; double y = 0.0; }; /* Affichage d'une position 2D */ static void afficher(Position2D p) { Ecran.afficherln("[",p.x,",",p.y,"]"); } /* Programme principal */ public static void main(String [] args) { int i; final int TAILLE = 10; /* Declaration du tableau tpos1 */ /* avec intialisation de ses champs */ /* lors de la declaration */ Position2D [] tpos1 = { new Position2D(), new Position2D(), new Position2D(), new Position2D(), new Position2D() }; /* Declaration du tableau tpos2 */ Position2D [] tpos2 = new Position2D[TAILLE]; /* Initialisation des composantes par programme */ for ( i = 0 ; i < TAILLE ; i++ ) tpos2[i] = new Position2D(); /* ******************************************** */ for ( i = 0 ; i < tpos1.length ; i++ ) afficher(tpos1[i]); Ecran.sautDeLigne(); for ( i = 0 ; i < tpos2.length ; i++ ) afficher(tpos2[i]); Ecran.afficherln(); } }