トップページ > プログラム > 2015年04月01日 > uyRJR5DZ

書き込み順位&時間帯一覧

48 位/141 ID中時間01234567891011121314151617181920212223Total
書き込み数0001000000000000000000001



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
★★Java質問・相談スレッド172★★ [転載禁止]©2ch.net

書き込みレス一覧

★★Java質問・相談スレッド172★★ [転載禁止]©2ch.net
756 :デフォルトの名無しさん[sage]:2015/04/01(水) 03:35:20.24 ID:uyRJR5DZ
public class SingletonTest {
 private final int foo;
 
 private static SingletonTest instance = null;

 private SingletonTest(int foo) {
  this.foo = foo; //←これ
 }

 public static SingletonTest newInstance(int foo) {
  if (instance != null) throw new AlreadyExistedException("already existed");
  return instance = new SingletonTest(foo);
 }

 public static SingletonTest getInstance() {
  return (instance == null) ? newInstance(1) : instance;
 }
}


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。