Output to with format in Java

Description

The following code shows how to output to with format.

Example


/*from w ww  .j av  a  2  s.c o m*/
import java.io.Console;
import java.sql.SQLException;

public class Main {
  public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
      System.err.println("sales: unable to obtain console");
      return;
    }

    console.printf("%s ", "string");
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter