IN101.cours7 ============ I.4 Classes enveloppes (Wrapper) a) a chaque type primitif correspond une classe enveloppe b) boite autour d'un attribut de type primitif + méthodes c) normalement même nom avec majuscule initiale : Long, Double, Boolean d) 2 exceptions quand abrégé : Integer, Character e) 3 nouveaux types primitifs : byte(8) short(16) float(32) et enveloppes correspondantes : Byte Short Float f) conversions : - (type) : non ! - primitif->enveloppe : constructeur int p1 = 12; Integer o2 = new Integer( p1 ); - enveloppe->primitif : méthode int p3 = o2.intValue(); généralement : xxxValue() avec xxx = type primitif - String->enveloppe : Integer o4 = new Integer( "12" ); - enveloppe->String : o4.toString() g) exemples d'autres méthodes : - int <- Integer.parseInt( String ) généralement : xxx <- Enveloppe.parseXxx( String ) avec xxx = type primitif - boolean <- Character.isDigit() .isLetter() .isLower() .toLowerCase() .isUpper() ...