码迷,mamicode.com
首页 >  
搜索关键字:equals == 对象比较    ( 4743个结果
java_String知识点
Java String == 和equals == 是用来比较字符串的引用地址,equals是比较字符串的值。 char[] 和String 安全敏感的信息char[] 存储要优于String,String是不可变的,这就意味着一旦被创建,就留在内存中,直到GC回收。使用数组存储方式,可以明确地改变数组中的元素,使用数组方式,安全信息将有可能不存在系统内存的任何地方。 switch语句 ...
分类:编程语言   时间:2015-02-08 09:11:24    阅读次数:185
8张图理解Java(转)
一图胜千言,下面图解均来自ProgramCreek网站的Java教程,目前它们拥有最多的票选。如果图解没有阐明问题,那么你可以借助它的标题来一窥究竟。1、字符串不变性下面这张图展示了这段代码做了什么12String s = "abcd";s = s.concat("ef");2、equals()方法...
分类:编程语言   时间:2015-02-08 00:24:22    阅读次数:132
leetcode 113. Path Sum II
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 andsum =...
分类:其他好文   时间:2015-02-07 14:23:22    阅读次数:169
hibernate学习:联合主键2
一:运行上一篇文章的程序会发现,后台输出两个warn 17:22:14,232  WARN RootClass:233 - composite-id class does not override equals(): com.hibernate.model.TeacherPK 17:22:14,234  WARN RootClass:238 - composite-id class does ...
分类:Web程序   时间:2015-02-06 21:57:40    阅读次数:178
leetcode 112. 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 given sum.Fo...
分类:其他好文   时间:2015-02-05 23:15:41    阅读次数:191
Comparable和Comparator实现对象比较
由文生义:继承Comparable ,表示该类的实例是可以相互比较的;继承Comparator,表示该类是一个比较器,里面设置了按什么属性比较,list需要按这个比较器里的规则来比较;使用方法如下:1.Comparablepublic class User implementsComparable{...
分类:其他好文   时间:2015-02-05 18:14:53    阅读次数:162
hashcode和equals的使用
hashcode和equals的使用 一、     说明   hashcode和equals都是用来判断对象是否相等的。   一般来讲equals是给代码编写者判断对象是否相等的,举个例子有个类只有名字属性,重写equals方法认为名字相等则对象相等,那么只要名字相同,对象便是相等的。   hashcode则一般是JDK来判断对象是否相等的,比如在set集合里面判断对象是否重复,就需要判断...
分类:其他好文   时间:2015-02-04 11:06:17    阅读次数:142
LeetCode[Tree]: 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 given sum.  For example:  Given the below binary tree and su...
分类:其他好文   时间:2015-02-03 23:08:01    阅读次数:196
LeetCode[Tree]: Path Sum II
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, return 这个题目适合用递归来解,我...
分类:其他好文   时间:2015-02-03 23:05:29    阅读次数:184
Comparable Comparator equals
为了让类的对象间可以排序,通常有两种方法——Comparable 与 Comparator。 Comparable泛型接口 int java.lang.Comparable.compareTo(T o) 本对象与参数进行对比。返回为负表示小于,零表示相等,正数表示大于。 Compares this object with the specified object for order. Re...
分类:其他好文   时间:2015-02-03 19:26:02    阅读次数:143
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!