随笔分类 -  代码块

摘要:import net.sourceforge.pinyin4j.PinyinHelper; public class PinyinHelperUtil { /** * 得到中文首字母(中国 -> ZG) * @param str 需要转化的中文字符串 * @return 大写首字母缩写的字符串 */ public static Stri... 阅读全文
posted @ 2017-09-19 17:06 ~~晴天~^.^ 阅读(4143) 评论(1) 推荐(0)
摘要:获取中文拼音(如:广东省 -->guangdongsheng) 获取中文首字母缩写(如:广东省-->gds) 获取中文首字母并把转化为大写字母(如:广东省--> G) 参考资料:http://blog.csdn.net/u013043346/article/details/50131341 阅读全文
posted @ 2017-09-12 17:38 ~~晴天~^.^ 阅读(2710) 评论(0) 推荐(0)
摘要:public static void main(String[] args) throws ParseException { // 获取当月的天数(需完善) SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); // 定义当前期间的1号的date对象 Date date = null; ... 阅读全文
posted @ 2017-09-12 17:00 ~~晴天~^.^ 阅读(4222) 评论(6) 推荐(1)
摘要://冒泡排序arr数组,sequence为true时,为升序排序;sequence为false时,为降序排序 for(int i = 0;i < arr.length;i++){ for(int j = 0;j < arr.length - i - 1;j++){ if(sequence && ar 阅读全文
posted @ 2017-08-24 15:27 ~~晴天~^.^ 阅读(231) 评论(0) 推荐(0)
摘要://获得2数的最大公约数 int a = y < x ? y : x; int b = x >= y ? x : y; int c = 1, e; // 定义c为最大公约数,d为最小公倍数,e为中间变量 while (b % a != 0) { e = b  阅读全文
posted @ 2017-08-24 15:26 ~~晴天~^.^ 阅读(195) 评论(0) 推荐(0)
摘要:单例模式要领:1.构造方法私有化2.对外提供一个公开的静态的获取当前类型对象的方法.3.提供一个当前类型的静态变量。 单例模式分为两种:饿汉式单例:在类加载阶段就创建了对象。懒汉式单例:用到对象的时候才会创建对象。 单例模式是23种设计模式中最简单的一种设计模式。 为了解决什么问题? 1. 为了保证 阅读全文
posted @ 2017-08-24 15:25 ~~晴天~^.^ 阅读(139) 评论(0) 推荐(0)