12月 022008
 

■nullpointerexception
・nullに対してメソッドを実行させようとしている場合。Stringがnullなのに、
型変換しようとしているなど。
オブジェクトが必要な場合に、アプリケーションが null を使おうとするとスロ
ーされます。たとえば、以下のような場合があります。
null オブジェクトのインスタンスメソッドの呼び出し
null オブジェクトのフィールドに対するアクセスまたは変更
null の長さを配列であるかのように取得
null のスロットを配列であるかのようにアクセスまたは修正
null を Throwable 値であるかのようにスロー

このエントリーをはてなブックマークに追加
はてなブックマーク - ■nullpointerexception エラー対応
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]

12月 022008
 

if-else文を簡略化した記述方法です。記入例ではxがtrueのときyを実行し、xがfalse
のときはzを実行することを意味します。

このエントリーをはてなブックマークに追加
はてなブックマーク - ■x ? y : z のような演算子 式
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]

11月 162008
 

■リファラ取得
request.setAttribute(“r” , request.getHeader(“REFERER”));
どのURLからきたのか、わかる。

このエントリーをはてなブックマークに追加
はてなブックマーク - リファラ取得 サーブレット getHeader
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]

11月 162008
 

■定数
定数の定義にはfinalを使う。
メソッド内での定義は、final int XXX=”xxx”;
フィールド変数のように、クラス内に定義する場合は、staticをはじめにつける

static final int XXX=”xxx”;

このエントリーをはてなブックマークに追加
はてなブックマーク - 定数
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]

10月 312008
 

■配列のソート

String[] a;
Arrays.sort(a);

■Mapのソート

Map map=new TreeMap();
この形でMapを作ると、keyをアルファベット順にソートしてくれる。

■Listのソート

Collections.sort(list);

このエントリーをはてなブックマークに追加
はてなブックマーク - 配列のソート Mapソート Listソート アルファベット順にソートする
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]