引言:从一个朋友的blog转过来的,里面解决了两个困扰我很久的问题。很有久旱逢甘霖的感觉。中软国际电子政务部Jeff Chi总结,转载请说明出处。概述:A.==可用于基本类型和引用类型:当用于基本类型时候,是比较值是否相同;当用于引用类型的时候,是比较对象是否相同。B.对于String a = “a...
分类:
编程语言 时间:
2014-06-26 22:01:25
阅读次数:
232
private boolean writeToSDCard(Throwable ex)
{
boolean isDealing = false;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
RandomAccessFile randomAccessFile = n...
分类:
移动开发 时间:
2014-06-26 11:58:42
阅读次数:
243
java.lang.Object.equals()函数默认情况下是不能用来比較组合对象的,比如密钥值。非常多Key类没有覆写equals()函数,因此,组合对象的比較必须单独比較里面的各个类型以保证正确性。[不符合安全要求的代码演示样例] 以下的代码使用equals()函数比較两个key值,k...
分类:
编程语言 时间:
2014-06-25 13:24:23
阅读次数:
248
第180页,倒数第三行。英文原文:Ifyouoverload==and!=,youmustalsooverridetheEquals()andGetHashCode()methodsinheritedfromSystem.Object;中文译文:在重载“==”和“!=”时,还必须重载(应该是:重写)从System.Object中继承的Equals()和GetHashCode()方法。
分类:
其他好文 时间:
2014-06-25 06:39:31
阅读次数:
162
检查android手机中是否存在某应程public boolean checkApp(String packageName) { if (packageName == null || "".equals(packageName)) return false; try { ApplicationInf...
分类:
移动开发 时间:
2014-06-24 09:16:50
阅读次数:
265
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum...
分类:
其他好文 时间:
2014-06-22 20:59:24
阅读次数:
227
java.lang.Object.equals()函数默认情况下是不能用来比较组合对象的,例如密钥值。很多Key类没有覆写equals()函数,因此,组合对象的比较必须单独比较里面的各个类型以保证正确性。
[不符合安全要求的代码示例]
下面的代码使用equals()函数比较两个key值,key值即使具有相同的取值也可能会返回不相等,导致结果出错。
private static b...
分类:
编程语言 时间:
2014-06-22 08:03:23
阅读次数:
275
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum = 22,
5
/ ...
分类:
其他好文 时间:
2014-06-21 22:44:58
阅读次数:
266
1.&和&&(1).&和&&都可以用作逻辑与的运算符,表示逻辑与(and),当运算符两边的表达式的结果都为true时,整个运算结果才为true.(2).&&还具有短路的功能,即如果第一个表达式为false,则不再计算第二个表达式.例如,对于if(str != null && !str.equals(...
分类:
编程语言 时间:
2014-06-21 16:24:29
阅读次数:
289