1.定义set中不允许放入重复的元素,使用equals()方法进行比较。如果返回true,两个对象的HashCode值也应该相等2.方法add():添加元素remove():移除指定元素.......TreeSet中常用的方法:first():返回第一个元素,last返回最后一个元素lower():...
分类:
编程语言 时间:
2015-08-06 13:11:55
阅读次数:
166
1.定义Map用于保存存在映射关系的数据.其中,key值不能重复(使用equals()方法比较),value值可以重复2.方法put(key,value):添加元素get(Object key):获取指定key的元素keySet():返回指定对象key的集合values():返回指定对象value的...
分类:
编程语言 时间:
2015-08-06 12:34:22
阅读次数:
134
可以使用如下方式:1. String.Compare(str1,str2)==0 或者 str1.CompareTo(str2)==02. str1.Equals(str2) 或者 String.Equals(str1,str2) 这种方式的话,需要注意null的情况
自己的理解:HashSet的底层结构用的是HashMap,当往HashSet上添加一条元素时。调用HashMap的put方法先调用hashCode()方法判断key的hash值是否一样,再调用对象的equals方法。...
分类:
其他好文 时间:
2015-08-05 18:33:17
阅读次数:
117
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-08-05 15:00:34
阅读次数:
112
题目: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 andsu...
分类:
其他好文 时间:
2015-08-05 06:38:24
阅读次数:
95
import java.util.ArrayList;
import java.util.Iterator;
/* 1.存入自定义对象,并且去除重复元素。
* 2.List集合判断元素是否相同,依据的是元素的equals方法。
* 心得:Object 里的equals方法判断的是对象的地址值是否相同。
* String 里的equals方法判断对象里内容是否相同。
...
分类:
编程语言 时间:
2015-08-04 11:15:20
阅读次数:
110
2015.7.29学习内容一.Switch选择结构1.回顾01.在Java中如何产生一个随机数Math.random()随机数范围:0到1,能取到0,取不到102.equals():在Java中,如果比较两个字符串用==的话,会出现错误,所以以后我们只要是对字符串类型进行对比,统一使用equals方...
分类:
其他好文 时间:
2015-08-03 01:07:56
阅读次数:
142
c#中 ==与equals有什么区别对于值类型、引用类型来说比较过程怎样的?using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class Person { p....
题目: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...
分类:
其他好文 时间:
2015-08-02 08:50:43
阅读次数:
91