How to use print format in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        int n = 194383;
        double f = 3.1415926;

        System.out.format("%d\n", n);
        System.out.format("%.2f", f);
    }
}


 
 
/*
run:
 
194383
3.14
 
*/

 



answered Nov 5, 2021 by avibootz

Related questions

1 answer 120 views
1 answer 124 views
1 answer 109 views
1 answer 122 views
1 answer 100 views
100 views asked Mar 30, 2022 by avibootz
1 answer 114 views
114 views asked Mar 30, 2022 by avibootz
1 answer 107 views
...