-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindFirstNonRepeatingChar.java
More file actions
35 lines (32 loc) · 976 Bytes
/
FindFirstNonRepeatingChar.java
File metadata and controls
35 lines (32 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package algorithmExamples;
/*
* @author Muhammed Fatih ÖZDİL
* @since Wed Mar 03 2021
*
*/
import java.util.Scanner;
public class FindFirstNonRepeatingChar {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("please enter a string: ");
String string = scanner.nextLine();
scanner.close();
char[] array = new char[string.length()];
for (int i = 0; i < string.length(); i++) {
array[i] = string.charAt(i);
}
for (int i = 0; i < array.length; i++) {
boolean check = false;
for (int j = i + 1; j < array.length; j++) {
if (array[i] == array[j]) {
check = true;
}
}
if (!check) {
System.out.println("the firstnonRepeating letter is :"
+ array[i]);
break;
}
}
}
}