0

hi

whats the meaning of these signs?

for example:

System.out.printf("%6s %6s %10s", "x1", "x2", "(y1, y2) \n");

Edited by gingerfish: n/a

4
Contributors
5
Replies
9
Views
7 Years
Discussion Span
Last Post by javaboy123
0

They format output. s formats strings, d formats integers, and f formats double precision floating point data (double). Basically you can use them to trim a string down so it only displays a set amount of characters ("%.2s", for two characters only as an example), rounds to a certain amount of decimal places ("%.5f" for 5 decimal places - if unspecified, it defaults to 6 decimal places), or to add commas to a large integer to make it easier to read ("%,d"). There are more things worth knowing about formatted output, google it and check out this web page.

0

They format output. s formats strings, d formats integers, and f formats double precision floating point data (double). Basically you can use them to trim a string down so it only displays a set amount of characters ("%.2s", for two characters only as an example), rounds to a certain amount of decimal places ("%.5f" for 5 decimal places - if unspecified, it defaults to 6 decimal places), or to add commas to a large integer to make it easier to read ("%,d"). There are more things worth knowing about formatted output, google it and check out this web page.

thanks :)

0
System.out.printf("%6s %6s %12s", "x1", "x2", "(y1, y2) \n");

output:

(6space) x1 (6space) x2 (6space) (y1, y2)

Edited by musthafa.aj: n/a

0
System.out.printf("%6s %6s %12s", "x1", "x2", "(y1, y2) \n");

output:

(6space) x1 (6space) x2 (6space) (y1, y2)

ThankQ, very clear :icon_cheesygrin:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.