Last active
November 6, 2016 20:19
-
-
Save brunodles/82d1d18d1c7a1287e1a50f0315d3b86f to your computer and use it in GitHub Desktop.
Medium - Java Formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.out.printf("%s", object); | |
String.format("%S -> %1$s", object.getValue()); | |
String.format("%i", object.getInteger()); | |
String.format("%2.2f", object.getFloat()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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