By jeffye, on February 19th, 2010

泛型是一种表示类或方法行为对于未知类型的类型约束的方法,比如 “不管这个方法的参数 x 和 y 是哪种类型,它们必须是相同的类型”,“必须为这些方法提供同一类型的参数” 或者 “foo() 的返回值和bar() 的参数是同一类型的”。虽然 String 是 Object 的子类,但是 List<String> 和 List<Object> 之间并没有什么关系——List<String> 不是 List<Object> 的子类或者子类型。
Wildcards
Consider the problem of writing a routine that prints out all the elements in a collection. Here’s how you might write it in an older version of the language (i.e., a pre-5.0 release):
void printCollection(Collection c) { [...]
By jeffye, on June 30th, 2009

Eclipse 无法自动编译 — 交叉引用
还是前人说得好,好记忆不如烂笔头。今天又被这个错误折腾了半天,Eclipse 突然莫名其妙的无法自动编译,依稀好像记得上次也出现这种情况,但今天半天都无法想得当初是如何找到原因的了。以后遇到这种错误还是得简单记录下来。
原因:两个工程互相引用会导致Eclipse 无法编译
Tricks: 遇到半天想不错原因的错误,建议打开windows–>Show View –> Problems , 一般会这里面会提示相应错误。
Incoming search terms for the article:eclipse web 自动编译 (1)eclipse 交叉编译 出错 (1)eclipse不能编译 (1)eclipse不能自动编译 (1)ubuntu eclipse 无法编译 (1)
By jeffye, on June 26th, 2009

使用Java Tar Package读取*.tar 或*.tar.gz 文件
Java Tar Package com.ice.tar 实现了一个tar 文档输入输出io包。使用方式接近java 中自带的 java.util.zip 包,所以也该非常容易上手,如果使用国java的zip包的话。
而且配合java 的中的GZIPInputStream 使用,就很容易实现.tar.gz 文件的访问。
步骤:
1. 读取文件,生成GZIPInputStream 流
2. 把1中生成的GZIPInputStream流传给 Java Tar Package 中的TarInputStream 流
过程非常简单,代码如下
private void visitTARGZ(P parser, File targzFile) throws IOException {
FileInputStream fileIn = null;
BufferedInputStream bufIn = null;
GZIPInputStream gzipIn = null;
TarInputStream taris = null;
try {
fileIn = new FileInputStream(targzFile);
bufIn = new BufferedInputStream(fileIn);
gzipIn = new GZIPInputStream(bufIn); //first [...]
By jeffye, on June 2nd, 2009

新机器换了ubuntu 系统,顺手也下了个最新版的Eclipse,没有到居然我最常用的快捷键代码提示Content Assist 从alt+/ 换成了ctrl+space, 真是没道理啊。 ctrl+space 对于中文用户来说一般都是用于拼音切换,这下可大麻烦了,强烈必是Eclipse设计者不考虑中文用户的使用习惯。今天是在忍不住了,找出来重新修改快捷键设置。以下备忘
Incoming search terms for the article:eclipse 快捷键设置 (140)eclipse 提示快捷键 (18)eclipse快捷键设置 (18)eclipse 快捷键 设置 (17)eclipse 设置快捷键 (13)
By jeffye, on May 20th, 2009

funny
Sent to you by Jeffye via Google Reader:
Java Multiplication (Much) Faster than Division
via LingPipe Blog by lingpipe on 5/13/09
Micro-benchmarking
I wrote this little micro benchmark to test it out:
public class MultiplyDivide {
public static void main(String[] args) {
for (int j = 0; j < 10; ++j) {
[...]