03 2013 档案
摘要:忘了在哪看到那个问题,引起了我的疑问,我在CSDN发了一个帖。我把代码帖上来,各位不妨先不看下面的解释,看看输出结果是什么class Test { private int t; Test(int t) { this.t = t; } static void changeRef(Test test) { test = new Test(1); } public static void main(String[] args) { Test test = new Test(2); change...
阅读全文
摘要:这两天看一个视频,写俄罗斯方块游戏的。发现他写的控制方块方向的是用静态常量来表示。即public static final int Left = 0;想想看了effective java,item 30 说过,要用enum代替int常量。我也就想当然地试了一下。由于之前没写过枚举,有的只是看过。果然出问题了错误示范,eclipse提示如下错误:The qualified case label Snake.Action.LEFT must be replaced with the unqualified enum constant LEFTpublic enum Action{ LEFT,...
阅读全文