next up previous contents index
Next: 18 Programmation système Up: Java: Le langage Previous: 16 Le package java.util

Subsections

17 Les types

 

17.1 Le package java.lang

Le package java.lang définit un ensemble de classes et interfaces qui consitue le noyau du langage Java .

Java , comme tout langage de programmation orienté objets, offre un certain nombre de classes et interfaces utiles au programmeur. L'ensemble de ces classes et interfaces sont regroupés dans le package java.util.

La version de jdk1.1 fournit pour ce package :

Les Classes:  
Boolean  
Byte  
Character  
Class  
ClassLoader  
Compiler  
Double  
Float  
Integer  
Long  
Math  
Number  
Object  
Process  
Runtime  
SecurityManager  
Short  
String  
StringBuffer  
System  
Thread  
ThreadGroup  
Throwable  
Void  


Les interfaces:  
Cloneable:  
Runnable:  

Quant à la version 1.2, ce même package comporte:


Les Classes:  
Boolean  
Byte  
Character  
Character.Subset  
Class  
ClassLoader  
Compiler  
Double  
Float  
Integer  
Long  
Math  
Number  
Object  
Package  
Process  
Runtime  
RuntimePermission  
SecurityManager  
Short  
String  
StringBuffer  
System  
Thread  
ThreadGroup  
ThreadLocal  
Throwable  
Void  


Les interfaces:  
Cloneable:  
Comparable::  
Runnable:  
Runtime.MemoryAdvice::  

17.2 Classes et types primitifs

  Rappelons qu'il n'est pas possible de transformer les types primitifs en objets par une opération de changement de type (cast ). Par contre, Java définit pour des classes spéciales pour un certain nombre de types primitifs (Integer, Float, Boolean, etc. Par exemple, on créera une instance de la classe Integer (qui n'est pas un int) ayant pour valeur 10 de la manière suivante :
 
Integer instanceInteger = new Integer(10);
Inversement la classe Integer dispose de méthode qui permettent d'obtenir la valeur du champ entier d'une instance de cette classe.
 
int i = instanceInteger.intValue();    // retourne 10

Les classes définies par Java pour les type primitifs sont les classes Boolean, Character, Number, Integer, Long, Float et Double.

17.3 La classe java.lang.Boolean

 
public final class Boolean {
    public static final Boolean TRUE = new Boolean(true)
    public static final Boolean FALSE = new Boolean(false)
    public Boolean(boolean value)
    public Boolean(String s)
    public String toString()
    public boolean equals(Object obj)
    public int  hashCode()
    public boolean booleanValue()
    public static Boolean  valueOf(String s)
    public static boolean getBoolean(String name);
}
 public Boolean (boolean value)
Constructeur de la classe Boolean qui prend en argument l'un des deux valeurs : true ou false.
 public Boolean (String s)
Constructeur de la classe Boolean qui prend en argument une chaîne de caractères. La chaîne de caractères "true" est transformée en instance de la classe Boolean contenant la valeur true et ce quelque soit la combinaison majuscule/minuscule. Tout autre chaîne de caractères sera considérée comme représentant false.
 public String toString ()
Redéfinition de la méthode toString de la classe Object.
 public boolean equals (Object obj)
Redéfinition de la méthode equals de la classe Object. Des instances de la classe Boolean sont égales si elles contient toutes deux la même valeur booléenne.
 public int hashCode ()
Retourne le hash code de l'objet.
 public boolean booleanValue ()
Retourne la valeur booléenne de l'objet.
 public static Boolean valueOf (String s)
Retourne la valeur booléenne représentée par la chaîne passé en argument. Equivalent à new Boolean(s).booleanValue().
 public static boolean getBoolean (String name)
Retourne true si name est la chaîne "true" avec n'importe quelle combinaison majuscule/miniscule.

17.4 La classe java.lang.Number

 
   public final class Number {
      public Number()
      public abstrct int intValue()
      public abstrct short shortValue()
      public abstrct int intValue()
      public abstrct long longValue()
      public abstrct float floatValue()
      public abstrct double doubleValue()
   }

17.5 La classe java.lang.Byte

 

   public final class Byte extends Number implements Comparable {
      public static final byte MIN_VALUE
      public static final byte MAX_VALUE
      public static final Class TYPE
      public Byte(byte value)
      public Byte(String s) throws NumberFormatException
      public static String toString(byte b)
      public static byte parseByte(String s) throws NumberFormatException
      public static byte parseByte(String s, int radix) throws NumberFormatException
      public static Byte valueOf(String s, int radix) throws NumberFormatException
      public static Byte valueOf(String s) throws NumberFormatException
      public static Byte decode(String nm) throws NumberFormatException
      public byte byteValue()
      public short shortValue()
      public int intValue()
      public long longValue()
      public float floatValue()
      public double doubleValue()
      public String toString()
      public int hashCode()
      public boolean equals(Object obj)
      public int compareTo(Byte anotherByte)
      public int compareTo(Object o)
   }

17.6 La classe java.lang.Short

 

   public final class Short extends Number implements Comparable {
      public static final short MIN_VALUE
      public static final short MAX_VALUE
      public static final Class TYPE
      public Short(short value)
      public Short(String s) throws NumberFormatException
      public static String toString(short s)
      public static short parseShort(String s) throws NumberFormatException
      public static short parseShort(String s, int radix) throws NumberFormatException
      public static Short valueOf(String s, int radix) throws NumberFormatException
      public static Short valueOf(String s) throws NumberFormatException
      public static Short decode(String nm) throws NumberFormatException
      public byte byteValue()
      public short shortValue()
      public int intValue()
      public long longValue()
      public float floatValue()
      public double doubleValue()
      public String toString()
      public int hashCode()
      public boolean equals(Object obj)
      public int compareTo(Short anotherShort)
      public int compareTo(Object o)
   }

17.7 La classe java.lang.Integer

 

   public final class Integer extends Number implements Comparable {
      public static final int MIN_VALUE
      public static final int MAX_VALUE
      public static final Class TYPE
      public Integer(int value)
      public Integer(String s) throws NumberFormatException
      public static String toString(int i, int radix)
      public static String toHexString(int i)
      public static String toOctalString(int i)
      public static String toBinaryString(int i)
      public static String toString(int i)
      public static int parseInt(String s, int radix) throws NumberFormatException
      public static int parseInt(String s) throws NumberFormatException
      public static Integer valueOf(String s, int radix) throws NumberFormatException
      public static Integer valueOf(String s) throws NumberFormatException
      public byte byteValue()
      public short shortValue()
      public int intValue()
      public long longValue()
      public float floatValue()
      public double doubleValue()
      public String toString()
      public int hashCode()
      public boolean equals(Object obj)
      public static Integer getInteger(String nm)
      public static Integer getInteger(String nm, int val)
      public static Integer getInteger(String nm, Integer val)
      public static Integer decode(String nm) throws NumberFormatException
      public int compareTo(Integer anotherInteger)
      public int compareTo(Object o)
   }

17.8 La classe java.lang.Long

 

   public final class Long extends Number implements Comparable {
      public static final long MIN_VALUE
      public static final long MAX_VALUE
      public static final Class TYPE
      public Long(long value)
      public Long(String s) throws NumberFormatException
      public static String toString(long i, int radix)
      public static String toHexString(long i)
      public static String toOctalString(long i)
      public static String toBinaryString(long i)
      public static String toString(long i)
      public static long parseLong(String s, int radix) throws NumberFormatException
      public static long parseLong(String s) throws NumberFormatException
      public static Long valueOf(String s, int radix) throws NumberFormatException
      public static Long valueOf(String s) throws NumberFormatException
      public byte byteValue()
      public short shortValue()
      public int intValue()
      public long longValue()
      public float floatValue()
      public double doubleValue()
      public String toString()
      public int hashCode()
      public boolean equals(Object obj)
      public static Long getLong(String nm)
      public static Long getLong(String nm, long val)
      public static Long getLong(String nm, Long val)
      public int compareTo(Long anotherLong)
      public int compareTo(Object o)
   }

17.9 La classe java.lang.Float

 

   public final class Float extends Number implements Comparable {
      public static float MAX_VALUE
      public static float MIN_VALUE
      public static float NaN
      public static float NEGATIVE_INFINITY
      public static float POSITIVE_INFINITY
      public static Class TYPE
      public Float(float value)
      public Float(double value)
      public Float(String s)
      public byte byteValue()
      public int compareTo(Float anotherFloat)
      public int compareTo(Object o)
      public double doubleValue()
      public boolean equals(Object obj)
      public static int floatToIntBits(float value)
      public float floatValue()
      public int hashCode()
      public static float intBitsToFloat(int bits)
      public int intValue()
      public static boolean isInfinite(float v)
      public boolean isInfinite()
      public static boolean isNaN(float v)
      public boolean isNaN()
      public long longValue()
      public short shortValue()
      public static String toString(float f)
      public String toString()
      public static Float valueOf(String s)
   }

17.10 La classe java.lang.Double

 

   public final class Double extends Number implements Comparable {
      public static double MAX_VALUE
      public static double MIN_VALUE
      public static double NaN
      public static double NEGATIVE_INFINITY
      public static double POSITIVE_INFINITY
      public static Class TYPE
      public Double(double value)
      public Double(String s)
      public byte byteValue()
      public int compareTo(Double anotherFloat)
      public int compareTo(Object o)
      public static long doubleToLongBits(double value)
      public double doubleValue()
      public boolean equals(Object obj)
      public float floatValue()
      public int hashCode()

      public int intValue()
      public static boolean isInfinite(double v)
      public boolean isInfinite()
      public static boolean isNaN(double v)
      public boolean isNaN()
      public static double longBitsToDouble(long bits)
      public long longValue()
      public short shortValue()
      public static String toString(double f)
      public String toString()
      public static Float valueOf(String s)
   }

17.11 La classe java.lang.Character

 
   public final class Number {
      public Character(char c)
      public int hashCode()
      public boolean equals(Object o)
      public String toString()
      public static boolean isLowerCase(char ch)
      public static boolean isTitleCase(char ch)
      public static boolean isDigit(char ch)
      public static boolean isDefined(char ch)
      public static boolean isLetter(char ch)
      public static boolean isLetterOrDigit(char ch)
      public static boolean isJavaIdentifierPart(char ch)
      public static boolean isJavaIdentifierStart(char ch)
      public static boolean isUnicodeIdentifierPart(char ch)
      public static boolean isUnicodeIdentifierStart(char ch)
      public static boolean isIdentifierIgnorable(char ch)
      public static char toLowerCase(char ch)
      public static char toUpperCase(char ch)
      public static char toTitleCase(char ch)
      public static int digit(char ch, int radix)
      public static int getNumericValue(char ch, int radix)
      public static boolean isSpaceChar(char ch)
      public static boolean isWhiteChar(char ch)
      public static boolean isISOControl(char ch)
      public static int getType(char ch)
      public static char forDigit(char ch)
   }

17.12 La classe java.lang.Math

La classe Math constitue la bibliothèque mathématique de Java . Toutes les méthodes de cette classe sont publiques et statiques.

 

   public final class Math {
      public static final double E
      public static final double PI
      public static double sin(double a)
      public static double cos(double a)
      public static double tan(double a)
      public static double asin(double a)
      public static double acos(double a)
      public static double atan(double a)
      public static double exp(double a)
      public static double log(double a)
      public static double sqrt(double a)
      public static double IEEEremainder(double f1, double f2)
      public static double ceil(double a)
      public static double floor(double a)
      public static double rint(double a)
      public static double atan2(double a, double b)
      public static double pow(double a, double b)
      public static int round(float a)
      public static long round(double a)
      public static double random()
      public static int abs(int a)
      public static long abs(long a)
      public static float abs(float a)
      public static double abs(double a)
      public static int max(int a, int b)
      public static long max(long a, long b)
      public static float max(float a, float b)
      public static double max(double a, double b)
      public static int min(int a, int b)
      public static long min(long a, long b)
      public static float min(float a, float b)
      public static double min(double a, double b)
   }


next up previous contents index
Next: 18 Programmation système Up: Java: Le langage Previous: 16 Le package java.util
Touraivane
6/12/1998