hi
whats the meaning of these signs?
for example:
System.out.printf("%6s %6s %10s", "x1", "x2", "(y1, y2) \n");
hi
whats the meaning of these signs?
for example:
System.out.printf("%6s %6s %10s", "x1", "x2", "(y1, y2) \n");
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)
System.out.printf("%6s %6s %12s", "x1", "x2", "(y1, y2) \n");
output:
(6space) x1 (6space) x2 (6space) (y1, y2)
ThankQ, very clear :icon_cheesygrin:
what does java mean
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.