【Java心得总结七】Java容器下——Map在自己总结的这篇文章中有提到hashCode,但是没有细究,今天细究整理一下hashCode相关问题1.hashCode与equals 首先我们都知道hashCode()和equals()函数是java基类Object的一部分,我查阅了java7文档,....
分类:
编程语言 时间:
2015-04-21 22:25:57
阅读次数:
322
题目来自于leetcode
https://leetcode.com/problems/path-sum/
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 ...
分类:
其他好文 时间:
2015-04-21 18:05:43
阅读次数:
156
JAVA集合类图:
1. hashmap原理,与hashtable区别
Java中的HashMap是以键值对(key-value)的形式存储元素的。HashMap需要一个hash函数,它使用hashCode()和equals()方法来向集合/从集合添加和检索元素。当调用put()方法的时候,HashMap会计算key的hash值,然后把键值对存储在集合中合适的索引上。如果key...
分类:
编程语言 时间:
2015-04-21 16:15:18
阅读次数:
264
创建string: string (char[]) 使用指定的字符串数组构建一个新的string对象 Copy(string) 使用指定的string构建一个新的string对象 比较函数: Compare(a,b) 和a.CompareTo(b) 相等返回0,大于返回正数,小于返回负数; ...
equalspublic boolean equals(Object obj)Indicates whether some other object is "equal to" this one.The equals method implements an equivalence relation...
分类:
编程语言 时间:
2015-04-21 00:12:25
阅读次数:
249
publicstaticvoidmain(String[]args)
{
System.out.println("欢迎使用XXX加密系统!");
Scannersc=newScanner(System.in);
while(true)
{
System.out.println("按1加密");
System.out.println("按2解密");
Stringfl=sc.nextLine();
switch(fl.toCharArray()[0])
{
case‘1‘:
..
分类:
其他好文 时间:
2015-04-19 06:48:54
阅读次数:
114
题目描述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...
分类:
其他好文 时间:
2015-04-18 22:01:55
阅读次数:
136
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters
per second, and in the end it is v2 meters
per second. We know tha...
分类:
其他好文 时间:
2015-04-18 20:38:35
阅读次数:
164
相等操作符==并不表示严格相等eg:var a = false;var b ="";if(a==b){ alert("a equals b");} 这个条件语句的求值结果是true,为什么?因为相等操作符==认为空字符串与false的含义相同。要进行严格比较,就要使用另一种等号(===)。这个全.....
分类:
其他好文 时间:
2015-04-18 15:54:32
阅读次数:
121
equals()
实现equals()
参数必须是Object,而不能是外围类
覆盖equals()时,也要覆盖相应的hashCode(),与equals(),保持一致
另外注意String的默认值是null
public class Person {
private String name;
private int birthYear;
byte[] raw;
@Ove...
分类:
编程语言 时间:
2015-04-17 20:29:34
阅读次数:
139