Exemple d’utilisation de la classe ‘Formatter’

Author:


Download

 
import java.util.*;
 
public class ClasseFormatter {
  public static void main(String args[]) {
    Formatter fmt;
 
    for(int i=1; i <= 30; i++) {
      fmt = new Formatter();
 
      fmt.format("%4d %4d %4dn", i, i*i, i*i*i);
      System.out.println(fmt);
    }
 
  }
}
/*
 * Affichage:
 *   1    1    1
 
   2    4    8
 
   3    9   27
 
   4   16   64
 
   5   25  125
 
   6   36  216
 
   7   49  343
 
   8   64  512
 
   9   81  729
 
  10  100 1000
 
  11  121 1331
 
  12  144 1728
 
  13  169 2197
 
  14  196 2744
 
  15  225 3375
 
  16  256 4096
 
  17  289 4913
 
  18  324 5832
 
  19  361 6859
 
  20  400 8000
 
  21  441 9261
 
  22  484 10648
 
  23  529 12167
 
  24  576 13824
 
  25  625 15625
 
  26  676 17576
 
  27  729 19683
 
  28  784 21952
 
  29  841 24389
 
  30  900 27000
 *
 *
 *
 *
 *
 *
 *
 **/

Cet article Exemple d’utilisation de la classe ‘Formatter’ est apparu en premier sur .