Java Formatter format characters

Introduction

To format an individual character, use %c.

It matches the character argument.

import java.util.*; 
 
public class Main { 
  public static void main(String args[]) { 
    Formatter fmt = new Formatter(); 
 
    fmt.format("Formatting %s is %S%c", "with Java", "easy", '!'); 
 
    System.out.println(fmt); /*  w w  w .j  av a2s.co  m*/

    fmt.close();
  } 
}



PreviousNext

Related