1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public class MainClass{
boolean b;//Type primitif
Truk t;//Pas primitif
//Constructeur
MainClass(){
b = false;
System.out.println("boolean AVANT modification : "+b);
this.modificationBoolean(b);
System.out.println("boolean APRES modification : "+b);//false, modificationBoolean n'a pas modifier le boolean puisque primitif
t = new Truk();
t.setTexte("bonjour tous le monde, il fait beau aujourd'hhui");
System.out.println("Truk AVANT modification : "+t.getTexte());
this.moficationTruk(t);
System.out.println("Truk APRES modification : "+t.getTexte());
}
public void modificationBoolean(boolean b){
b =true;
}
public void moficationTruk(Truk t){
t.setTexte("Bonsoir madames, il pleuvait hier") ;
}
public static void main(String[] args) {
new MainClass();
}
} |