原始版本:templatevoid swap(T& a, T& b){ T tmp(a); a = b; b = tmp;}此版本不重视效率,当交换的两个对象比较大时,需要更高效的交换,因此应该提供1)public swap成员函数,让它高效的置换两个对象,并提供nono-memb...
分类:
其他好文 时间:
2014-07-07 19:06:21
阅读次数:
179
Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>...
分类:
其他好文 时间:
2014-07-07 16:59:12
阅读次数:
169
String 内容定义成 final char[],只能在属性和构造函数中赋值,其它地方不能改变 ;String 覆盖实现了 equals 。StringBuffer 内容定义成了 char[] ,但没实现 equals。String 和 StringBuffer 的区别是:1、String 通过构...
分类:
编程语言 时间:
2014-07-01 23:32:09
阅读次数:
266
上回书说道:灰常灰常基本的数据类型
下面咱们来点高级的:
Tuples 元组
元组存储一对键值,并且没有类型限制
let http404Error = (404, "Not Found")
// http404Error is of type (Int, String), and equals (404, "Not Found")书上废话一堆,反正元组就是这么写,上面的例子还...
分类:
其他好文 时间:
2014-07-01 06:55:09
阅读次数:
236
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-28 07:31:28
阅读次数:
214
例证:string peom1 = "Kubla Khan";string peom2 = "Kubla Khan"; string peom3 = String.Copy(peom2); Boolean b1 = peom1.Equals(peom2); //true Boo...
分类:
其他好文 时间:
2014-06-27 18:52:25
阅读次数:
169
String中==与equals的区别:==比较字符串中的引用相等equals比较字符串中的内容相等(因为字符串有重写equals方法)例子:/************ String中的equals与== *****************//* * ==比较字符串中的引用相等 * equals比较...
分类:
其他好文 时间:
2014-06-27 14:58:42
阅读次数:
121
1、代码
User.java
public class User{
String name;
int age;
public User(String name,int age){
this.name = name;
this.age = age;
}
public boolean equals(Object obj){
if(this == ...
分类:
编程语言 时间:
2014-06-27 09:29:17
阅读次数:
261
1. "==" 和 equals
(1) == 用于判断引用对象的内存地址是否相同。
(2) equals比较的也是地址, 但是如果你重写了equals方法, 那么它就可以比较对象的内容。
2. 关于sizeof
C和C++的sizeof()用于获取数据需要占用多少字节的内存, 之所以需要sizeof是考虑到平台移植, 因为C和C++相同的数据类型在不同的机器上...
分类:
编程语言 时间:
2014-06-27 08:31:59
阅读次数:
259