MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / ArrayDemo

Class ArrayDemo

day13/code/day13_Array_Arrays/src/cn/itcast_04/ArrayDemo.java:8–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 *�������abcdefg��
7 */
8public class ArrayDemo {
9 public static void main(String[] args) {
10 // �����ַ���
11 String s = "dacgebf";
12
13 // ���ַ���ת���ַ�����
14 char[] chs = s.toCharArray();
15
16 // ���ַ������������
17 bubbleSort(chs);
18
19 // ���������ַ�����ת���ַ���
20 String result = String.valueOf(chs);
21
22 System.out.println(result);
23 }
24
25 public static void bubbleSort(char[] chs) {
26 for (int x = 0; x < chs.length - 1; x++) {
27 for (int y = 0; y < chs.length - 1 - x; y++) {
28 if (chs[y] > chs[y + 1]) {
29 char temp = chs[y];
30 chs[y] = chs[y + 1];
31 chs[y + 1] = temp;
32 }
33 }
34 }
35 }
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected