随笔 - 395  文章 - 3  评论 - 49  阅读 - 85万
03 2014 档案
堆排序
摘要: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 阅读(175) 评论(0) 推荐(0) 编辑
Clone Graph
摘要:这里使用BFS来解本题,BFS需要使用queue来保存neighbors但这里有个问题,在clone一个节点时我们需要clone它的neighbors,而邻居节点有的已经存在,有的未存在,如何进行区分?这里我们使用Map来进行区分,Map的key值为原来的node,value为新clone的node,当发现一个node未在map中时说明这个node还未被clone,http://oj.leetcode.com/problems/clone-graph/ 1 public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {... 阅读全文
posted @ 2014-03-21 18:45 wf110 阅读(322) 评论(0) 推荐(0) 编辑
java写 excel
摘要:http://blog.csdn.net/windows1989/article/details/7237052 阅读全文
posted @ 2014-03-17 22:05 wf110 阅读(145) 评论(0) 推荐(0) 编辑
矩阵连乘最小权值
摘要:http://blog.csdn.net/liufeng_king/article/details/8497607 阅读全文
posted @ 2014-03-14 12:42 wf110 阅读(244) 评论(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 阅读(201) 评论(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 阅读(653) 评论(0) 推荐(0) 编辑
正则表达式
摘要:http://blog.csdn.net/xymyeah/article/details/1629480 阅读全文
posted @ 2014-03-11 14:19 wf110 阅读(202) 评论(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 阅读(346) 评论(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 阅读(456) 评论(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 阅读(223) 评论(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 阅读(607) 评论(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 阅读(236) 评论(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 阅读(1304) 评论(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 阅读(767) 评论(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 阅读(14509) 评论(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 阅读(246) 评论(0) 推荐(0) 编辑
着重protected、default区别
摘要:public是所有,在哪都可以访问private是私有,仅在自己类里面可以访问protected是自己包里面可以访问,如果有不同包的类想调用它们,那么这个类必须是定义它们的类的子类。default也是自己包里面可以访问,而且不能被其它包里面的子类访问。调用和直接使用的区别:调用强调新建了对象并且使用其下函数, 而直接使用一般在继承关系中直接用到父类的函数。作用域 当前类 同一package(不管子类还是被新建对象调用) 子孙类(不同包内继承关系的直接使用) 其他package(不同包内不是子孙关系的新建对象调用)public √ √ ... 阅读全文
posted @ 2014-03-05 13:27 wf110 阅读(404) 评论(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 阅读(157) 评论(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 阅读(141) 评论(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 阅读(174) 评论(0) 推荐(0) 编辑
块的作用
摘要:1 for(int i=0;i<10;i++)2 Integer k=new Integer(i);for循环可以不使用{}的,但仅限于执行语句(其中并不包括变量声明语句),由于这段代码在main中重复定义了Integer k,所以编译会出错,只要加上{},让变量声明在块内就可以了,块结束后,块内局部变量会被释放。 阅读全文
posted @ 2014-03-03 21:46 wf110 阅读(257) 评论(0) 推荐(0) 编辑
字符串 组合打印
摘要:1 static void DFS(List list,String str,int n) 2 { 3 System.out.println(str); 4 for (int i=0;i<list.size();i++) 5 { 6 LinkedList link=new LinkedList(list); 7 8 DFS(link,str+link.remove(i),++n); 9 }10 }View Code 用于处理字符串 ... 阅读全文
posted @ 2014-03-03 15:23 wf110 阅读(184) 评论(0) 推荐(0) 编辑
Java容器集合类的区别用法
摘要:Set,List,Map,Vector,ArrayList的区别JAVA的容器---List,Map,SetCollection├List│├LinkedList│├ArrayList│└Vector│ └Stack└SetMap├Hashtable├HashMap└WeakHashMapCollection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements)。一些 Collection允许相同的元素而另一些不行。一些能排序而另一些不行。Java SDK不提供直接继承自Collection的类,Java . 阅读全文
posted @ 2014-03-03 13:25 wf110 阅读(268) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示