From Thinking in Java 4th Editionfinal1. 对于基本类型,final使数值恒定不变2. 对于对象引用,final使引用恒定不变,即不能指向别的对象,但指向的对象本身可以改变(The same for array in Java)import java.util....
分类:
编程语言 时间:
2015-03-19 23:34:15
阅读次数:
246
From Thinking in Java 4th Edition并发线程可以驱动任务,因此你需要一种描述任务的方式,这可由Runnable接口来提供。要想定义任务,只需要实现Runnable接口,并编写run()方法,使得该任务可以执行你的命令。public class LiftOff imple...
分类:
编程语言 时间:
2015-03-19 23:32:39
阅读次数:
240
From Thinking in Java 4th EditionRTTI(Run-Time Type Information),运行时类型信息,使得你可以在程序运行时发现和使用类型信息。对RTTI的需要,揭示了面向对象设计中许多有趣(并且复杂)的问题,同时也提出了如何组织程序的问题。Java是如何...
分类:
编程语言 时间:
2015-03-19 23:24:20
阅读次数:
175
problem:
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
将1-3999的整数转换为罗马数字
thinking:
(1)
对照举例
个位数举例
Ⅰ,1 】Ⅱ,2】 Ⅲ,3】 Ⅳ,4 】Ⅴ,5 】Ⅵ...
分类:
其他好文 时间:
2015-03-18 18:11:35
阅读次数:
92
problem:
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
将罗马数字转为整数
thinking:
(1)罗马数字规则:
罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)...
分类:
其他好文 时间:
2015-03-18 18:09:37
阅读次数:
130
problem:
Write a function to find the longest common prefix string amongst an array of strings.
寻找 0 ~n 个字符串的最长公共前缀
thinking:
(1)公共前缀很好理解,按位匹配即可
(2)很容易忘记处理0、1个字符串的情况。
code:
string prefi...
分类:
其他好文 时间:
2015-03-18 18:05:15
阅读次数:
112
最近开始读tij,好急性不如烂笔头,所以还是记录一下,方便以后查阅。
方法重载的问题:
方法的重载,区别是靠传入方法的参数,而不是返回值。比如f(),如果是返回值的话,容易产生歧义。
方法的重载中,会出现传入参数的类型提升或者降低;比如说如果有个方法可以接受int型,如果传入一个char类型,调用...
分类:
编程语言 时间:
2015-03-18 16:01:01
阅读次数:
174
problem:
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of conv...
分类:
其他好文 时间:
2015-03-17 22:00:59
阅读次数:
163
problem:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
thinking:
(1)整型反转直观很容易理解。如正负,尾数为0等问题还好处理。
(2)反转溢出问题要仔细处理。
code:
class Solution {
public:
...
分类:
其他好文 时间:
2015-03-17 18:04:05
阅读次数:
132
这里大概就只能生成两种类型的图:
序列图
流程图
序列图```sequence
A->B: 一句话证明你很寂寞。 神回复:
Note right of B: thinking
B->B: counting
B-->A: 这句话有一共六十九笔
```
Created with Raphaël 2.1.2AABB一句话证明你很寂寞。 神回复:thinkingcounting这句话有一共六十九笔序列图很简...
分类:
其他好文 时间:
2015-03-16 23:15:22
阅读次数:
208