for (int i = 0; i < str1.length(); i++) { String c = str1.substring(i, i + 1); for (int j = 0; j < str2.length(); j++) { String d = str1.substr