-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcharacter1.java
More file actions
39 lines (28 loc) · 741 Bytes
/
Copy pathcharacter1.java
File metadata and controls
39 lines (28 loc) · 741 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
36
37
38
import java.util.*;
public class character1
{
public static void main(){
Scanner sc =new Scanner(System.in);
System.out.println("enter the string");
String n = sc.nextLine();
int n1=n.length();
char arr[] = new char[n1];
for(int i=0;i<n1;i++){
arr[i]=n.charAt(i);
// System.out.println(arr[i]);
}
char temp=' ';
for(int i=0;i<n1;i++){
for(int j=0;j<n1-1;j++){
if(arr[j]>arr[j+1]){
temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(int i=0;i<n1;i++){
System.out.print(arr[i]);
}
}
}