strncmp method
Compares up to n characters of the string str1 to those of the string str2.
Implementation
int strncmp(String str1, String str2, int n) {
int len1 = min(str1.length, n);
int len2 = min(str2.length, n);
String s1 = str1.substring(0, len1);
String s2 = str2.substring(0, len2);
return s1.compareTo(s2);
}