Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally i...
分类:
其他好文 时间:
2014-07-02 17:56:50
阅读次数:
205
覆盖equals时,遵守通用约定
对equal方法的覆盖看起来很简单,但是有许多情况是容易导致错误,最好的避免这些错误的办法
就是不覆盖equals方法.
必须遵循的原则:
自反性--对于任何非空的引用 x,有x.equals(x) 为true;
对称性--对于任何非空的引用x,y,如果x.equals(y) 为true,则必有y.equals(x) 为true;
传递...
分类:
其他好文 时间:
2014-07-02 17:03:19
阅读次数:
142
An L-value is something that can appear on the left side of an equal sign,An R-value is something that can appear on the right side of an equal sign.....
分类:
其他好文 时间:
2014-07-02 10:08:37
阅读次数:
295
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
分类:
其他好文 时间:
2014-07-02 10:01:21
阅读次数:
173
==:1、比较的是操作符两端的操作数是否是同一个对象2、两边的操作数必须是同一类型的(可以是父子类之间)才能编译通过。3、比较的是地址,如果是具体的阿拉伯数字的比较,值相等则为TRUE,如:int a=10 与 long b=10L 与 double c=10.0都是相同的(为true),因为他们都...
分类:
其他好文 时间:
2014-06-30 13:04:40
阅读次数:
191
java.io.File.equal()比较两个File对象是否指向同一个文件,但实际上不同系统的文件系统中,需要小心使用,以免被坑。...
分类:
其他好文 时间:
2014-06-29 22:24:55
阅读次数:
224
一般认为:==比较的是基础数据的值或者是对象的引用地址equal()比较的是对象的内容其实:==和equal()都是比较的引用地址,其实是栈内存中变量(包括基本数据类型的变量和对象变量)的值equals()方法在object类中定义如下:public boolean equals(Object ob...
分类:
编程语言 时间:
2014-06-28 17:11:04
阅读次数:
265
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal...
分类:
其他好文 时间:
2014-06-25 23:01:44
阅读次数:
227
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the o...
分类:
其他好文 时间:
2014-06-25 12:14:23
阅读次数:
159
题目链接:http://acm.upc.edu.cn/problem.php?id=2170题意:给出一个字符串,比如ABACA,在这个串里,AB、BA、AC、CA各出现一次。若存在另外一个串,里面也AB、BA、AC、CA各出现一次。我们称ABACA是不唯一的。给出一个串,判断其是不是唯一。 思路:...
分类:
其他好文 时间:
2014-06-23 00:22:22
阅读次数:
274