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");
one question about printf()
Moderator: admin
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: one question about printf()
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.
Please check how width and precision work for strings.
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
Re: one question about printf()
this is very helpful, thank u.
Who is online
Users browsing this forum: No registered users and 4 guests