How to find out the adjacent word pairs from a string in java? -
i have string good , want find out word pairs string such oo , if string success out put should cc ss without using string's built in functions in java.
possible?
without any built-in method - no. 1 or 2 - can
char previous = 0; char[] chars = str.tochararray(); (int = 0; < chars.length(); i++) { if (chars[i] == previous) { system.out.println(previous + "" + previous); } previous = chars[i]; } i prefer i < str.length() , str.charat(i), uses more string methods.
Comments
Post a Comment