-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.java
More file actions
79 lines (71 loc) · 1.47 KB
/
Test.java
File metadata and controls
79 lines (71 loc) · 1.47 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.Scanner;
public class Test {
// public static void main(String arg[]) {
// int arr[] = { 0, 1, 4, 0, 3, 0, 4, 0 };
// for (int i : arr)
// System.out.print(i + " ");
// int x = 0;
// for (int i = 0; i < arr.length - 1; i++) {
// if (arr[i] == arr[i + 1]) {
// arr[x] = arr[i];
// x++;
// }
// }
// while (x < arr.length) {
// arr[x] = 0;
// x++;
// }
// System.out.println("\n============================");
// for (int i : arr)
// System.out.print(i + " ");
// }
// public static void main(String arg[]) {
// int num = 38;
// int sum =0;
// do{
// sum =0;
// while(num>0)
// {
// sum+=num%10;
// num/=10;
// }
// num = sum;
// }while(num>=10);
// System.out.println("Sum = "+ sum);
// }
// public static void main(String arg[]) {
// int arr[] ={1,0,3,5,5,7};
// int n=10;
// for(int i=0;i<n;i++)
// {
// boolean flag = true;
// for(int j=0;j<arr.length;j++)
// {
// if(i==arr[j])
// {
// flag = false;
// break;
// }
// }
// if(flag) System.out.print(i+" ");
// }
// }
public static void main(String[] args) {
String str = "aabbdee";
int c=0;
for (int i=0;i<str.length();i++)
{
c=1;
char ch = str.charAt(i);
for(int j=i+1;j<str.length();j++)
{
if(ch ==str.charAt(j))
{
str = str.substring(0,j)+str.substring(j+1);
c++;
}
}
System.out.println(str.charAt(i)+" occurred "+ c);
}
}
}