// **THIS FUNCTION USED TO GET FIRST THREE CHARACTER FROM STRING
public String getFirstThreeChar(String str) {
String first3;
first3 = str.substring(0, Math.min(str.length(), 3));
return first3;
}
// **THIS FUNCTION USED TO GET LAST THREE CHARACTER FROM STRING
public String getLastThreeChar(String str) {
String last3;
if (str == null || str.length() < 3) {
last3 = str;
} else {
last3 = str.substring(str.length() - 3);
}
return last3;
}
public String removeLastThreeChar(String s) {
if (s == null || s.length() == 0) {
return s;
}
return s.substring(0, s.length() - 3);
}
public String getFirstThreeChar(String str) {
String first3;
first3 = str.substring(0, Math.min(str.length(), 3));
return first3;
}
// **THIS FUNCTION USED TO GET LAST THREE CHARACTER FROM STRING
public String getLastThreeChar(String str) {
String last3;
if (str == null || str.length() < 3) {
last3 = str;
} else {
last3 = str.substring(str.length() - 3);
}
return last3;
}
public String removeLastThreeChar(String s) {
if (s == null || s.length() == 0) {
return s;
}
return s.substring(0, s.length() - 3);
}
No comments:
Post a Comment