Advertisement
cd62131

Formatter Example

Nov 25th, 2013
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.41 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Formatter;
  3.  
  4. public class FormatExample {
  5.   public static void main(String[] args) {
  6.     Scanner in = new Scanner(System.in);
  7.     int a = 0;
  8.     try {
  9.       a = new Integer(in.next());
  10.     }
  11.     catch (Exception e) {
  12.     }
  13.     in.close();
  14.     Formatter formatter = new Formatter();
  15.     formatter.format("%02d", a);
  16.     System.out.println(formatter);
  17.   }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement