决定认真的看一遍《Thinking in Java》

前两天同事给我发了一封邮件,好像是从CSDN上看来的。内容如下:

不编译执行,你预测一下输出。然后再验证一下。

 public class Test2 extends Test1
{
 
 {
  System.out.print("1");
 }
 
 Test2() {
  System.out.print("2");
 }
 
 static {
  System.out.print("3");
 }
 
 {
  System.out.print("4");
 }
 
 public static void main(String[] args) {
  new Test2();
 }
}

class Test1 {
 Test1(){
  System.out.print("5");
 }
 
 static{
  System.out.print("6");
 }
}

我认为答案是635214,结果却是635142,受打击啊。后来同事告诉我"同类中按静态、非静态循序、构造,继承按类父类到子类的循序"。为了测试我是否理解,又给我出了一道题:

 public class Test2 extends Test1{

    {
        System.out.print("1");
    }

    Test2(){
        super(3);
        System.out.print("2");
    }

    static{
        System.out.print("3");
    }

    {
        System.out.print("4");
    }

    public static void main(String[] args) {
        System.out.print("7");
        new Test2();
    }
}

class Test1 {

    Test1(int i){
        System.out.print("5"); 
    }
    static{
        System.out.print("6");
    }
}

结果我又错了,正确的答案是6375142。

于是我狂受打击!看来有必要认真地看一遍《Thinking in Java》啦,这本书大四的时候买的,却一直没有仔细看过,只是草草翻了一下。而且我又总是太功利,喜欢看那些立即见效的书,现在看来还是不行啊。跟我情况一样的朋友,一起回过头来看《Thinking in Java》,也好互相交流互相学习啊。

《J2ME游戏开发(第一版)》错误反馈单01

……详细信息请进入……

1、脚踏车去J2ME:

37页:Graphics.TOP|raphics.LEFT是不是应该改成Graphics.TOP|Graphics.LEFT 啊好象找不到变量。

 

2deaboway:

71页:没级——》每级

 

3、好香的鱼头:

我看了你翻译的最后章,你说翻译的不好,我看还可以,好象主要是些代码,我发现一些作者本身的小问题:

P182–P185

1

P184

static final Font lowFont = Font.getFont(Font.FACE_MONOSPACE,

Font.STYLE PLAIN, Font.SIZE SMALL);

很奇怪,书上的_号没显示出来,而复制粘贴的时候可以看到

 

2

P183

少了一句话(Because the highlight menu font is enlarged we base space between menu times on the larger font.)大至意思是:因为高亮度菜单的字体被扩大了,我们需要让选项于选项之间设置一定的距离.

下面一些是作者的单词拼错了

1.原文:作者那本书p212

There really isn't much code, what we need to do here is center the menu items based on

the number items and the size of font. Because the highlight menu font is enlarged we

base space between menu times(这里好象是items而不是times) on the larger font. See the code comments for more

information. Its farily self-explantory(explantory好象拼写错了,应该为explanatory少了个a)

2.原文 Main Midlet SimleCustomMenu.java:

 //这里估计作者想打的是SimpleCustomMenu(少了个p)

还有些作者程序的地方设计的有点不是很好

比如在最后段:// Simple Run — Should be modified for better performance/efficiency

public void run() {

while(true) {

repaint();

}

}

我试过,这样很容易死机,起码要加一句:

try {

  Thread.sleep(100);

 } catch (InterruptedException e) {

  e.printStackTrace();

 }

看了几个小时,发现你水平不错,很多地方看看你文章还是有很大帮助的,感谢中.我这几个星期比较忙,剩下的一些地方可能要等我考好试才能看,谢谢你

 

请准备加入MIDP2.0 API文档翻译的人给我留言

      为了避免重复劳动,请准备加入MIDP2.0 API文档翻译的人给我留言,或者直接跟我联系。从12月20号正式开始MIDP2.0 API文档中文化工作。我考虑先将它们翻译成中文,而后再加入一些实例,从而可以更好的指导大家的编程工作。

      我的联系方式请参考第一帖,当然,最好能给我发邮件