hi

whats the meaning of these signs?

for example:

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

Edited 6 Years Ago by gingerfish: n/a

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.

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 :)

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

output:

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

Edited 6 Years Ago by musthafa.aj: n/a

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.