Last active
April 2, 2018 18:38
-
-
Save amihalik/e6c85e88ec48873ef9b6259b84ddbd83 to your computer and use it in GitHub Desktop.
Six String example
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
public class foo { | |
public static void main(String[] args) throws Exception { | |
String long_string = "asdfasdf123456"; | |
String six_string = "123456"; | |
String five_string = "12345"; | |
String one_string = "1"; | |
String empty_string = ""; | |
System.out.println(six_string(long_string)); | |
System.out.println(six_string(six_string)); | |
System.out.println(six_string(five_string)); | |
System.out.println(six_string(one_string)); | |
System.out.println(six_string(empty_string)); | |
} | |
public static String six_string(String str){ | |
return str.substring(Math.max(0, str.length()-6), str.length()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment