Page 1 of 1
one question about printf()
Posted: Sat Mar 22, 2014 1:14 am
by icepeanuts
I tried the code below. The result is "hell". But I do not understand why. Could anyone help me out? Thanks.
System.out.printf("%3.4s\n", "hello world");
Re: one question about printf()
Posted: Sat Mar 22, 2014 10:57 am
by admin
It is quite straight forward. Please go through this:
http://web.cerritos.edu/jwilson/SitePag ... erence.pdf
Please check how width and precision work for strings.
Re: one question about printf()
Posted: Sat Mar 22, 2014 5:18 pm
by icepeanuts
this is very helpful, thank u.