Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ex17 {
- public static void main(String[] args) {
- String word = "abcabcXyyzzf";
- char[] singleChar = new char[word.length()];
- String[] checkArray = new String[word.length()];
- for (int i = 0; i < singleChar.length; i++) {
- singleChar[i] = word.charAt(i);
- for (int j = 0; j < singleChar.length; j++) {
- singleChar[j] = word.charAt(j);
- if (singleChar[i] == singleChar[j] && i != j) {
- checkArray[i] = "repeated";
- }
- }
- if (checkArray[i] != "repeated") {
- System.out.println("First non-repeating character in word - " + word + " - is " + singleChar[i] + " at index: " + i);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement