How to format integers into a String using String.format() in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            String s = String.format("A: %d B: %d C: %d", 100, 200, 300);
            System.out.println(s);

        } catch (Exception e) {
            System.out.print(e.toString());
        }
    }
}

/*
             
run:

A: 100 B: 200 C: 300
    
 */

 



answered Nov 29, 2016 by avibootz
...