Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does the % % mean in java?

Im a PHP-programmer and wonder what this line means.

System.out.printf("exp(%.3f) is %.3f%n", x, Math.exp(x))

what does %.3f, %.3f%n and the comma x means?

like image 428
ajsie Avatar asked Jul 01 '26 05:07

ajsie


2 Answers

It is similar to C's printf:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax

like image 176
Doug Porter Avatar answered Jul 03 '26 18:07

Doug Porter


PHP has a similar function: http://php.net/printf The Documentation of the Java version can be found here: http://java.sun.com/javase/6/docs/api/java/util/Formatter.html

like image 27
Malax Avatar answered Jul 03 '26 18:07

Malax