随笔分类 -  java study

上一页 1 2 3 4 下一页
两个线程交替打印字符串
摘要:每个对象都有一内置锁wait方法 释放对象锁(不占对象锁)sleep方法不释放对象锁(占对象锁)优秀写法 (下面写法可能有问题,synchronized (LOCK) 提到 while前面就好了) 1 class Info { 2 String printStr = "i think thi... 阅读全文
posted @ 2014-04-11 11:02 wf110 阅读(7994) 评论(0) 推荐(0)
堆排序
摘要:1 public class MyHeapSort { 2 3 private static void OutPrint(int nums[]) 4 { 5 for(int i:nums) 6 System.out.print(i+" "); 7 System.out.println(); 8 } 9 public static void main(String[] args) {10 int numbers[]=new int[]{1,5,2,7,4,2,8,34};11 ... 阅读全文
posted @ 2014-03-29 15:25 wf110 阅读(179) 评论(0) 推荐(0)
java写 excel
摘要:http://blog.csdn.net/windows1989/article/details/7237052 阅读全文
posted @ 2014-03-17 22:05 wf110 阅读(152) 评论(0) 推荐(0)
矩阵连乘最小权值
摘要:http://blog.csdn.net/liufeng_king/article/details/8497607 阅读全文
posted @ 2014-03-14 12:42 wf110 阅读(252) 评论(0) 推荐(0)
leetcode Word Break I II 算法分析
摘要:http://blog.csdn.net/cs_guoxiaozhu/article/details/14104789http://oj.leetcode.com/problems/word-break-ii/ 阅读全文
posted @ 2014-03-13 19:24 wf110 阅读(207) 评论(0) 推荐(0)
LinkedHashMap插入无序且链式操作
摘要:1 Iterator> ite=lhmap.entrySet().iterator();2 ite.next();3 ite.remove(); 删除前到后的元素4 ite.next();5 ite.remove();6 lhmap.put(key, value); LinkedHashMap lhmap=new LinkedHashMap(capacity,0.75f,true);L... 阅读全文
posted @ 2014-03-12 11:15 wf110 阅读(656) 评论(0) 推荐(0)
正则表达式
摘要:http://blog.csdn.net/xymyeah/article/details/1629480 阅读全文
posted @ 2014-03-11 14:19 wf110 阅读(207) 评论(0) 推荐(0)
母函数写法
摘要:1 import java.awt.Point; 2 import java.io.BufferedInputStream; 3 import java.util.ArrayList; 4 import java.util.List; 5 import java.util.Map; 6 import java.util.Scanner; 7 8 public class Main { 9 10 static int T=0,n=0,knum=0,sum=0,count=0; 11 // public static void dfs(List list,i... 阅读全文
posted @ 2014-03-07 23:32 wf110 阅读(350) 评论(0) 推荐(0)
容易犯错的面试题
摘要:1 public static void main(String[] args) { 2 // Exams 1: 3 { 4 System.out.println("examples "+count++ +": "); 5 x--; 6 System.out.println(x); 7 myMethod(); 8 System.out.println(x+y+++x); 9 } 10 //Exams 2: 11... 阅读全文
posted @ 2014-03-07 18:31 wf110 阅读(460) 评论(0) 推荐(0)
约瑟夫
摘要:1 ArrayList list=new ArrayList(); 2 for(int i=1;i<8;i++) 3 list.add(i); 4 final int which=8; 5 int countNum=0; 6 int index=0; 7 8 while(list.isEmpty()==false) 9 {10 countNum=countNum+1; //计数用的11 ... 阅读全文
posted @ 2014-03-06 18:31 wf110 阅读(229) 评论(0) 推荐(0)
快排写法
摘要:1 private static void qsort_asc(int source[],int low,int high) 2 { 3 if(lowsource[i])17 i++;18 if(isource[low])15 low++;16 if(low<high)17 source[high]=source[low];18 }19 ... 阅读全文
posted @ 2014-03-06 14:17 wf110 阅读(611) 评论(0) 推荐(0)
读空格隔开字符
摘要:1 Scanner cin = new Scanner(new BufferedInputStream(System.in));2 int a;3 while (cin.hasNextInt())4 {5 a = cin.nextInt();6 System.out.print(a+" ");7 } 阅读全文
posted @ 2014-03-06 14:14 wf110 阅读(241) 评论(0) 推荐(0)
递归输出出栈所有可能
摘要:1 private static void DFS(Deque in,Stack stack,Deque out) { 2 if(0==in.size()) //输入队列空了 3 { 4 if(0==stack.size()) //栈也空了 输出结果 5 { 6 for(Object obj:out.toArray()) 7 System.out.print(obj); 8 ... 阅读全文
posted @ 2014-03-06 10:15 wf110 阅读(1307) 评论(0) 推荐(0)
递归遍历全排列个人见解
摘要:针对递归有两种模式。1.针对原数据进行修改。2.每次都new出数据放入递归。1. 1 private static boolean visited[]=new boolean[num]; 2 private static void DFS(List str,String out,int count) { 3 // if(visited[0]==true&&visited[1]==true&&visited[2]==true&&visited[3]==true) 4 if(count==num) //判断条件... 阅读全文
posted @ 2014-03-05 19:20 wf110 阅读(770) 评论(0) 推荐(0)
?super T 和? extends T区别
摘要:Java 泛型关键字说明? 通配符类型 表示类型的上界,表示参数化类型的可能是T 或是 T的子类 表示类型下界(Java Core中叫超类型限定),表示参数化类型是此类型的超类型(父类型),直至Objectextends 示例static class Food{}static class Fruit extends Food{}static class Apple extends Fruit{}static class RedApple extends Apple{}List flist = new ArrayList();// complie error:// flist.add(new A 阅读全文
posted @ 2014-03-05 17:01 wf110 阅读(14568) 评论(1) 推荐(4)
构造函数调用虚函数先从子类搜索同名函数
摘要:1 class X 2 { 3 X() 4 { 5 System.out.println("x"); // 6 vir(44); //看到vir会先搜索子类中的vir是否存在,如果不存在再调用父类中的vir 7 } 8 9 public void vir(int x)10 {11 System.out.println("X VIR");12 }13 }14 class Z extends X{15 16 ... 阅读全文
posted @ 2014-03-05 14:26 wf110 阅读(254) 评论(0) 推荐(0)
着重protected、default区别
摘要:public是所有,在哪都可以访问private是私有,仅在自己类里面可以访问protected是自己包里面可以访问,如果有不同包的类想调用它们,那么这个类必须是定义它们的类的子类。default也是自己包里面可以访问,而且不能被其它包里面的子类访问。调用和直接使用的区别:调用强调新建了对象并且使用其下函数, 而直接使用一般在继承关系中直接用到父类的函数。作用域 当前类 同一package(不管子类还是被新建对象调用) 子孙类(不同包内继承关系的直接使用) 其他package(不同包内不是子孙关系的新建对象调用)public √ √ ... 阅读全文
posted @ 2014-03-05 13:27 wf110 阅读(408) 评论(0) 推荐(0)
static不实现多态
摘要:1 class Father 2 { 3 4 public static String getName() 5 { 6 return "father"; 7 } 8 } 9 10 class Children extends Father11 { 12 public static String getName()13 {14 return "children";15 }16 }17 public class staticTest {18 public static void main(Strin... 阅读全文
posted @ 2014-03-05 11:17 wf110 阅读(161) 评论(0) 推荐(0)
内部类嵌套
摘要:1 public class XZ 2 { 3 static class b 4 { 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 System.out.println("test"); 8 } 9 }10 }这种写法也是正确的 阅读全文
posted @ 2014-03-04 21:46 wf110 阅读(146) 评论(0) 推荐(0)
构造函数顺序
摘要:1 class X 2 { 3 X() 4 { 5 System.out.println("x"); //2 6 } 7 Y y=new Y(); //1 8 } 9 class Y10 {11 12 Y()13 {14 System.out.println("y");15 }16 }17 class Z extends X{18 19 /**20 * @param args21 */22 ... 阅读全文
posted @ 2014-03-04 21:44 wf110 阅读(175) 评论(0) 推荐(0)

上一页 1 2 3 4 下一页