public static int countNoOfSentance(String str){
StringBuffer strBuffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) != '.' && str.charAt(i) != '?') {
strBuffer.append(str.charAt(i));
} else {
++count;
strBuffer = new StringBuffer();
}
}
count++;
System.out.println(count);
return count;
}
StringBuffer strBuffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) != '.' && str.charAt(i) != '?') {
strBuffer.append(str.charAt(i));
} else {
++count;
strBuffer = new StringBuffer();
}
}
count++;
System.out.println(count);
return count;
}
No comments:
Post a Comment