Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今日から使いたくなるifとfor

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for イシカワ イシカワ
November 23, 2019

 今日から使いたくなるifとfor

JJUG CCC 2019FallでLightning Talkしたスライドです。
コードに関してのご意見は受け付けます。

Avatar for イシカワ

イシカワ

November 23, 2019
Tweet

Other Decks in Business

Transcript

  1. 研修でまなんだこと 3 資料作成 Tips プロジェク ト管理基礎 インタ ビュー モデリング ファシリ

    テーション 見積り 業務フロー プログラミ ング クラウドイ ンフラ Webシステ ム構築
  2. ifとforの万能性 • ソート 5 public static void main(String args[]) {

    int[] array = { 8, 3, 3, 4, 5 }; for (int i = 0; i < array.length - 1; i++) { for (int j = array.length - 1; j > i; j--) { if (array[j] < array[j - 1]) { int tmp = array[j - 1]; array[j - 1] = array[j]; array[j] = tmp; } } } } → ifとforで出来る!
  3. ifとforの万能性 • 業務ロジック 6 public static void main(String args[]) {

    for(int i = 0; i < visiter.size(); i++){ if(visiter.getPass().isExistAAA){ user.add(visiter[i]); } if(visiter.isBBB){ break; } } for(int i = 0; i < user.size(); i++){ if(user.isLogin()){ if(user.isXXX){ doXXX(); } else if(user.isYYY) { doYYY(); } else if(user.isXXX){ doZZZ(); } } } } → ifとforで出来る!
  4. ifとforの万能性 • Javaの中身もifとforで出来てる! 7 public static long parse(String s) {

    ・・・ for (k = wtb.length; --k >= 0;) if (wtb[k].regionMatches(true, 0, s, st, i - st)) { int action = ttb[k]; if (action != 0) { if (action == 1) { // pm if (hour > 12 || hour < 1) break syntax; else if (hour < 12) hour += 12; } else if (action == 14) { // am ・・・ } } } }
  5. ifとforの万能性 • 女の子の落とし方 8 public static void main(String args[]) {

    TalkResult result = talk(); if(result.getLINE()){ for(int i = 0; i < 365; i++){ sendMessage(); } } } → ifとforで出来る! if(tooManyMessage()){ break; }
  6. ifとforの万能性 • 私の一日 9 public static void main(String args[]) {

    sleep(); for(int i = sleepiness(); i == 0; i--){ if(sleepy()){ goToBed(); } else { goToWork(); } } } → ifとforで出来る!
  7. ifとforの万能性 • 私の一日 10 public static void main(String args[]) {

    sleep(); → ifとforで出来る! wakeUp(); goToWork(); for(int i = 0; i < task; i++){ doTask(); if(teiji()){ break; } } goBackHome(); }
  8. 最後に・・・ 12 if & for Love public static void main(String

    args[]) { for(int i = 0; i < JJUG_CCC_LT.time; i++){ stayHere(); if(Audience.clapHand()){ break; } } }