- 博客(4)
- 收藏
- 关注
原创 用两个线程交替输出a-z (线程安全)
/** * 两个线程 交替输出啊a -z 相当于交替输出计数偶数 */public class Demo02 { public static void main(String[] args) { Chars chars = new Chars(); Thread t1 = new Thread(new A(chars)); Thread t2 = new Thread(new B(chars)); t1.setName("线..
2022-03-31 10:31:33
197
原创 1.已知字符串“adhflkalkfdhasdkhflsa”(1)统计去掉重复后的字符(2)统计每个字符出现的次数,使用map存储,字符为键,次数为值。(3)遍历map,打印统计信息
public class Demo01 { public static void main(String[] args) { String str = "adhflkalkfdhasdkhflsa"; //将字符串转换成字符数组 char[] chars = str.toCharArray(); //得到一个Map的数组,用来存储每个字符和字符出现的次数 Map<Character, Integer> ma.
2022-03-22 20:27:42
804
原创 传入一个字符串进行去重处理。
public class Demo01 { public static void main(String[] args) { String str = "abcdefgacdrfg"; //调用去重的方法 removeDup(str); } /** * @Description: 去重的方法 * @Param: [str] 传入要去重的字符串 * @return: void */ p.
2022-03-22 20:19:29
321
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人