Pass value array to String.format() in Java

Description

The following code shows how to pass value array to String.format().

Example


//from   ww w  .ja  v  a2  s.com
public class Main {
  public static void main(String args[]) {
    System.out.printf("Hi %s at %s", "value", "value 2");

    String a[] = { "value 1", "value 2" };

    System.out.println(String.format("hi %s at %s", a));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter