How to use printf() in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        int x = 24, y = 4000;
        double f = 3.14159;
     
        System.out.printf("%d, %d\n", x, y); 
        System.out.printf("%.2f\n", f); 
        System.out.printf("%10d", x); 
    }
}
 
 
 
/*
run:
 
24, 4000
3.14
        24
 
*/

 



answered Jun 30, 2020 by avibootz

Related questions

2 answers 199 views
1 answer 121 views
1 answer 145 views
145 views asked Dec 19, 2023 by avibootz
2 answers 183 views
1 answer 132 views
132 views asked Jun 6, 2023 by avibootz
...