Exemplo n.º 1
0
 // programme de test de la classe Clavier
 public static void main(String[] args) {
   System.out.println("donnez un flottant");
   float x;
   x = Clavier.lireFloat();
   System.out.println("merci pour " + x);
   System.out.println("donnez un entier");
   int n;
   n = Clavier.lireInt();
   System.out.println("merci pour " + n);
   System.out.println("donnez un caractère");
   char c;
   c = Clavier.lireChar();
   System.out.println("merci pour " + c);
 }
Exemplo n.º 2
0
 public static void main(String args[]) {
   try {
     int t[];
     System.out.print("taille voulue : ");
     int n = Clavier.lireInt();
     t = new int[n];
     System.out.print("indice : ");
     int i = Clavier.lireInt();
     t[i] = 12;
     System.out.println("*** fin normale");
   } catch (NegativeArraySizeException e) {
     System.out.println("Exception taille tableau negative : " + e.getMessage());
   } catch (ArrayIndexOutOfBoundsException e) {
     System.out.println("Exception indice tableau : " + e.getMessage());
   }
 }