Integer一类的比较问题】的更多相关文章

总体主要分为两个方面 ①比较的是值 一.基本数据类型与引用数据类型进行比较时,引用数据类型会进行拆箱(自动拆装箱需要在jdk1.5以上),然后与基本数据类型进行值的比较 举例: int i = 12; Integer j = new Integer(12); i == j 返回的是true 二.引用数据类型与基本数据类型进行比较(equals方法),基本数据类型会进行自动装箱,与引用数据类型进行比较,Object中的equals方法比较的是地址,但是Integer类已经重写了equals方法,只…
String类 字符串是不可变的,对其做的任何改变,会生成一个对象,不会改变有原有对象. ==和equals() String s1 = "good"; String s2 = "good"; if (s1 == s2) {} // true 这种直接把字符串赋值给对象的情况,是存储在常量池里的,指向同一个地址 // another example String s1 = "good"; String s2 = new String("…
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 之前那篇文章写的是罗马数字转化成整数(http://www.cnblogs.com/grandyang/p/4120857.html), 这次变成了整数转化成罗马数字,基本算法还是一样.由于题目中限定了输入数字的范围(1 - 3999), 使得题目变得简单了不少. 基本字符 I V…
思考一下我们接触的最小割问题 最小割的基本问题(可能会和图论的知识相结合,比如bzoj1266,bzoj1797) 最大权闭合图(bzoj1497) 最大点权覆盖集,最大点权独立集(bzoj1324) 最近接触到了一类关于最小割新的问题,我也不知道叫什么好 反正它有这么几个特点 每个点都有两种选择的可能性,设为属于S和属于T,属于S有收益a[i],属于T有收益b[i] 两点之间可能因为同在一个或不在同一个集合内产生额外的收益 使收益最大化(废话) 大概就是这个意思,如果看不懂也没关系,我们先从最…
1.  String to Integer (atoi) Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is inte…
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be spe…
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 解释: 罗马数字采用七个罗马字母作数字.即Ⅰ(1).X(10).C(100).M(1000).V(5).L(50).D(500).记数的方法: 相同的数字连写,所表示的数等于这些数字相加得到的数,如 Ⅲ=3: 小的数字在大的数字的右边,所表示的数等于这些数字相加得到的数,如 Ⅷ=8.…
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which i…
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! If the integer'…
Integer.parseInt 处理一个空字符串, 结果出错了, 程序没有注意到,搞了很久, 引发了血案啊!! 最后,终于 观察到了, 最后的部分: Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.lk.common.util.LKUtil 还以为是class 不存在呢!! 于是,反复的复制啊, 黏贴啊, 我擦, 明明LKUtil就在那里的啊!!! 怎么回事! 实际原因就是这个啊: Caused…