Exemple de justification des caractères à gauche et à droite

Author:


{filelink=4423}


import java.util.Formatter;

public class Justification {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();

    // Justifier à droit
    fmt.format("|%10.2f|", 250.2352);
    System.out.println(fmt);

    // Justification à gauche
    fmt = new Formatter();
    fmt.format("|%-10.2f|", 250.2352);
    System.out.println(fmt);
  }
}

/*

|    250,24|
|250,24    |

*/

Leave a Reply

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