本文共 364 字,大约阅读时间需要 1 分钟。
将汉字的首字母转为拼音码,在软件中使用拼音码模糊搜索,用以提示用户的体验感。
一、引入hutool 工具依赖
cn.hutool hutool-all
二、使用工具类提供的转首字母的方法
public static void main(String[] args) { String chinese="zZ中国J阿拉伯"; String pym= PinyinUtil.getAllFirstLetter(chinese); System.out.println(pym); }
三、结果
总结:生活是慢慢积累的,技能也是如此,要善用工具类,要解决实际问题用起来就好。
转载地址:http://ljnab.baihongyu.com/