Java Formatter(Locale l) Constructor
Syntax
Formatter(Locale l) constructor from Formatter has the following syntax.
public Formatter(Locale l)
Example
In the following code shows how to use Formatter.Formatter(Locale l) constructor.
import java.util.Formatter;
import java.util.Locale;
//w ww . j a v a2 s . com
public class Main {
public static void main(String[] args) {
Formatter formatter = new Formatter(Locale.getDefault());
// format a new string
String name = "from java2s.com";
formatter.format("Hello %s !", name);
// print the formatted string
System.out.println(formatter);
// flush the formatter. Here it does nothing.
formatter.flush();
System.out.println("Formatter Flushed.");
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »