Created
November 10, 2016 12:32
-
-
Save IOAyman/05a862c37df13e854932cdef3211bb8b to your computer and use it in GitHub Desktop.
LLC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
// Création de la liste | |
Liste l = new Liste(); | |
// Construction des éléments | |
TMaillon three = new TMaillon(13, null); | |
TMaillon two = new TMaillon(12, three); | |
TMaillon one = new TMaillon(11, two); | |
// initialisation de la tete | |
l.setTête(one); | |
// On doit d'abord récupérer la tête de la liste pour pouvoir la parcourire | |
TMaillon head = l.getTête(); | |
// Tanque la tête n'est pas null => ye3ni la tete fiha une valeur | |
while (head != null) { | |
// Afficher la valeur | |
System.out.println(head.info); | |
// Passer au prochain élément dans la liste | |
head = head.suivant; | |
} | |
} | |
} | |
class Liste { | |
private TMaillon tête; | |
TMaillon getTête() { | |
return tête; | |
} | |
void setTête(TMaillon tête) { | |
this.tête = tête; | |
} | |
} | |
class TMaillon { | |
int info; | |
TMaillon suivant; | |
public TMaillon() { | |
} | |
TMaillon(int info, TMaillon suivant) { | |
this.info = info; | |
this.suivant = suivant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment