Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. String s = "0123456789";
  2.  
  3. String result = String.format("[%1$15s]", s); //returns [ 0123456789]
  4.  
  5. String result = String.format("[%1$-15s]", s); // returns [0123456789 ]
  6.  
  7. String result = String.format("[%1$.5s]", s); // returns [01234]
  8.  
  9. String result = String.format("[%1$-.5s]", s); // throws MissingFormatWidthException
  10.  
  11. String result = String.format("[%1$-0.5s]", s); // throws MissingFormatWidthException
  12.  
  13. String result = String.format("[%1$.-5s]", s); // throws UnknownFormatConversionException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement