Escape Formatter % sign in Java

Description

The following code shows how to escape Formatter % sign.

Example


/*from   w ww . java  2  s .  c o m*/
import java.util.*; 
 
public class Main { 
  public static void main(String args[]) { 
    Formatter fmt = new Formatter(); 
 
    fmt.format("Copying file%nTransfer is %d%% complete", 88); 
    System.out.println(fmt); 
  } 
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter