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