Skip to content

Instantly share code, notes, and snippets.

@brunodles
Last active November 6, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunodles/82d1d18d1c7a1287e1a50f0315d3b86f to your computer and use it in GitHub Desktop.
Save brunodles/82d1d18d1c7a1287e1a50f0315d3b86f to your computer and use it in GitHub Desktop.
Medium - Java Formatter
System.out.printf("%s", object);
String.format("%S -> %1$s", object.getValue());
String.format("%i", object.getInteger());
String.format("%2.2f", object.getFloat());
String string = "this should start with a capital letter";
// first way
string = string.substring(0, 1).toUppercase() + string.substring(1);
// second way
char[] chars = string.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
string = new String chars;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment