随笔分类 -  编程题

摘要:/** * 斐波那契数列 */public static int fib(int n){ if(n==1) return 0; if(n==2) return 1; return fib(n-1) + fib(n-2);} 阅读全文
posted @ 2019-05-13 12:28 keepup~ 阅读(107) 评论(0) 推荐(0)
摘要:/** * 单例模式:懒汉式 */class Singleton{ private static volatile Singleton singleton = null; private Singleton(){ } public static Singleton getInstance(){ if 阅读全文
posted @ 2019-05-13 12:05 keepup~ 阅读(127) 评论(0) 推荐(0)
摘要:/** * 冒泡排序 * @param arr */public static void bubbleSort(int [] arr){ for(int i= 0;i < arr.length -1;i++){ for (int j=0;j < arr.length-1-i;j++){ if(arr 阅读全文
posted @ 2019-05-13 12:04 keepup~ 阅读(177) 评论(0) 推荐(0)
摘要:public class ManyThreads2 { private int j = 0; public synchronized void inc() { j++; System.out.println(Thread.currentThread().getName() + "inc" + j); 阅读全文
posted @ 2019-05-09 18:54 keepup~ 阅读(928) 评论(0) 推荐(0)
摘要:public static void test(String str){Map<String,Integer> map = new HashMap<>();for(int i = 0 ;i < str.length();i++){String s = str.charAt(i) + "";if(ma 阅读全文
posted @ 2019-05-09 18:07 keepup~ 阅读(3268) 评论(0) 推荐(0)
摘要:public String reverse(String str){ if(str == null || str.length() <= 1){ return str; } return reverse(str.subString(1)) + str.charAt(0); } 阅读全文
posted @ 2019-05-09 17:17 keepup~ 阅读(4414) 评论(0) 推荐(0)