網頁

2011年3月22日 星期二

Java Identifier & Keyword

identifier -> name of a variable, a method, or a class
keyword -> CANNOT be used as an identifier

identifier 的4種組成:
  1. letter, A-Za-z
  2. currency character, $
  3. underscore, _
  4. number, 0-9
  • 前3種可以做為 identifier的開頭, 第4種 number[0-9] 不可放在 identifier 的第1個位置.
  • 長度沒有限制
  • case-sensitive
Legal:
  • int _a;
  • int $c;
  • int ______2_w;
  • int _$;
  • int this_is_a_very_detailed_name_for_an_identifier;
Illegal:
  • int :b;
  • int -d;
  • int e#;
  • int .f;
  • int 7g;
keyword 有50個:

2011年3月11日 星期五

ToWriteList

  1. java string constant/literal pool
    • String str = new String("abc"); 幾個 ojbects 會被產生?
  2. throw Exception, SecurityException, Throwable while method does not have thows declaration
    • 原本的 method 沒有寫要 thows Exception, 但為何可以 thow SecurityException?
    • 而且~~為何不能 thow Throwable?
  3. Eclipse will generate strange byte code that will call Display.getHeight() but not Canvas.getHeight()
    • try to reproduce this first!

2011年3月8日 星期二

語文練習

這週來了位外國同事~
同樣是台灣出生~卻不太會中文~
聽說是來一年~為了學中文!

staff travel: 員工旅遊
bargain: noun 減價品, 便宜貨           verb 討價還價, 殺價?

2011年2月21日 星期一

Is Sun's javac used in Eclipse?

NO. Eclipse has its own Java compiler.

http://www.eclipse.org/jdt/core/
JDT Core is the Java infrastructure of the Java IDE. It includes:
An incremental Java compiler. Implemented as an Eclipse builder, it is based on technology evolved from VisualAge for Java compiler. In particular, it allows to run and debug code which still contains unresolved errors.

Reference:
How to change to use SUN JAVAC compiler [message #112141]
sun vs eclipse autoboxing difference

2011年1月3日 星期一

JavaME Preverify

c:/Java_ME_platform_SDK_3.0/bin/preverify.exe
-classpath stubclasses.zip\;../client/preverified\;tmpclasses
-d classes
tmpclasses

Java Cross-Compilation

$JAVA_HOME/bin/javac
-bootclasspath stubclasses.zip
-source 1.3 -target 1.3
-d tmpclasses/
-classpath ../client/preverified
-sourcepath src/game/internal
src/game/internal/com/xyz/media/feature/function/track/GetStateTests.java
2>&1 | tee build4.log

2010年12月17日 星期五

Tricky initialization of a declaration in C

int main( void )
{
    int x = ( x = 10, x += x, x );

    printf("x=%d\n", x);

    return 0;
}

2010年6月10日 星期四

Linux 下的源程序查看工具

http://www.linuxsir.org/bbs/showthread.php?t=237551

我用下来的感觉是(在debian sid中)
(g)vim + ctags + taglist + cscope + cppcomplete + global

大型程序一定要global的参与,它的分析比较全面。

taglist 精干,需要ctags的支撑 ,直接可以在左边列出函数列表,全局参数列表。(可以排序)

cscope 比较强大,可以对函数以及部分类型定义进行跳转,但有些BUG,好像在某些条件下无法正确找到分析枚举的定义。

cppcomplete 需要ctags的支撑,可以补全类型或者函数名(可不是普通Ctrl+P/N的那种)

global 新版本可以嵌入vim使用,提供比较完整解析和类型索引,和cscope比,稍微差些的就是对类型引用的打印列表中没有标识这个引用在什么函数中进行的。

这些都在我平常的使用中,部分功能还在摸索中。

2010年5月20日 星期四

Java Anonymous Instance

對話框通常只會出現一下下, 用來提示使用者採取某些行動. 當使用者做完決定後, 這個對話框就會消失.

使用匿名類別顯示一個對話框, 亦即建立一個匿名的實體. 當運行完這個對話框後, 系統會自行回收這個匿名實體所佔用的記憶體空間, 從而讓程式在運行中不會佔到不必要的記憶體空間.