Autobox et unbox: Exemple des types booléens et caractères*

Author:


{filelink=11196}


public class BooléenEtCharBox{
  public static void main(String args[]) {

    Boolean b = true;

    //Ici, le b est auto-unboxé lorsqu'il est utilisé dans une expression conditionelle.
    if(b)
    {
        System.out.println("b égal à true");
	}

    Character ch = 'x'; // boxer un char
    char ch2 = ch; // unboxer un char

    System.out.println("ch2 est " + ch2);
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *