Contoh implementasi startWith :
Contoh Implementasi codePointAt :
l itu tabel ascii-nya 108,.. So codePointAt itu ngeluarin integer ascii suatu char... :D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public String frontTimes(String str, int n) { String result = ""; if(str.length() > 2) { String x = str.substring(0, 3); while(n>0) { result += x; n -= 1; } }else { while(n>0) { result += str; n -= 1; } } return result; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | public String frontTimes(String str, int n) { int frontLen = 3; if (frontLen > str.length()) { frontLen = str.length(); } String front = str.substring(0, frontLen); String result = ""; for (int i=0; i<n; i++) { result = result + front; } return result; } |