数字反转,不能使用字符串或其它工具类
int num = 12345;
int n = 0;
do {
n = (n * 10) + (num % 10);
num = num / 10;
} while (num > 0);
System.out.println(n);//54321
基本类型和包装类型的对比
Integer a1 = new Integer(1);
Integer a2 = 1;
int a3 = 1;
System.out.println(a1 == a2); // false
System.out.println(a1 == a3); //true
System.out.println(a2 == a3); //true
System.out.println(a1.equals(a2)); //true
System.out.println(a1.equals(a3)); //true
System.out.println(a2.equals(a3)); //true
最简单的分词算法
public static void main(String[] args) {
String work = "230078912345234";
final int outLen = work.length();
for (int i = 0; i < outLen; i++) {
for (int j = i; j < outLen + 1; j++) {
final String key = work.substring(i, j);
System.out.println(key);
}
}
}
2
23
230
2300
23005
230052
2300523
23005234
3
30
300
3005
30052
300523
3005234
0
00
005
0052
00523
005234
0
05
052
0523
05234
5
52
523
5234
2
23
234
3
34
4
自定义一个出栈入栈的代码