find first repeating letter in a string
print first repeated element
- public class Array2 {
- public static void main(String[] args) {
- /*String s="ffaghglklklh";
- Outer:for(int i=0;i<s.length();i++){
- Innter: for(int j=i+1;j<s.length();j++){
- if(s.charAt(i)==s.charAt(j)){
- System.out.println(s.charAt(i));
- break Outer;
- }
- }
- }*/
- int[] arr={1,2,3,4,5,0,0,1,3};
- Outer:for(int i=0;i<arr.length;i++){
- Innter: for(int j=i+1;j<arr.length;j++){
- if(arr[i]==arr[j]){
- System.out.println(arr[i]);
- break Outer;
- }
- }
- }
- }
- }
Comments
Post a Comment