Trap Questions in Java and Obj-C

7a78f23eef1b0e883ef44c229a54f0bb?s=47 417.72KI
December 03, 2019

Trap Questions in Java and Obj-C

7a78f23eef1b0e883ef44c229a54f0bb?s=128

417.72KI

December 03, 2019
Tweet

Transcript

  1. 4XJGU,PUMJOѪ޷ձ 7PM !(.0ϖύϘ

  2. 4XJGUͱ,PUMJO

  3. 4XJGUͱ,PUMJO

  4. +BWBͱ0CKFDUJWF$ ͷ࿩Λ͠·͢

  5. ͳΜͰࠓ͞Β+BWB0CK$

  6. ͳΜͰࠓ͞Β+BWB0CK$ w ࠓͷ࣌୅ΞϓϦ͸4XJGU,PUMJOͰॻ͘ͷ͕౰ͨΓલ w ࠓͲ͖+BWB0CK$ͳΜͯ৮ΒΜ΍Ζ

  7. Ռͨͯ͠ຊ౰ʹͦ͏ͩΖ͏͔ʁ

  8. Ռͨͯ͠ຊ౰ʹͦ͏ͩΖ͏͔ʁ w 044ϥΠϒϥϦ͸ϦϦʔε͞Εͨ࣌୅΍ϥΠϒϥϦͷಛ ੑ্+BWB0CK$Ͱॻ͔Ε͍ͯΔ΋ͷ΋·ͩ·ͩଟ͍ w ࣮૷Λ֬ೝͨ͠Γ13Λग़ͨ͠Γ͢ΔͳΒ΍ͬͺΓͦͷล ͷ஌ࣝ͸ඞཁ

  9. ͱ͍͏͜ͱͰ

  10. ҙ֎ͱҾ͔͔ͬΔʂʁ ݴޠ࢓༷ΫΠζ +BWB0CKFDUJWF$ฤ

  11. w 5BLVIJSP.VUBBLB௣໊Նر ,*  w 4&೥ 8FC J04 "OESPJE ৽ਓݚमߨࢣFUD

    
 J04 डୗ։ൃ ೥൒
 J04 ࣗࣾ։ൃ ࠓίί w 5XJUUFS 2JJUB@LJ
 (JU)VC,* w 4XJGUѪ޷ձࢀՃप೥
 ΋͏΍ΜΧϨʔ͸೥໨ ͓લ୭Α
  12. #VJME$POpHTXJGU ελʔ͍ͩ͘͞

  13. ݴޠ࢓༷ΫΠζ w +BWB໰ w 0CKFDUJWF$໰

  14. +BWBฤ

  15. ୈ໰

  16. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ

  17. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { while (false) { System.out.println("hoge"); } } }
  18. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { while (false) { System.out.println("hoge"); } } } lIPHFz͕ճ͚ͩग़ྗ͞ΕΔ Կ΋ى͖ͳ͍ ίϯύΠϧΤϥʔ ࣮ߦ࣌Τϥʔ
  19. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { while (false) { System.out.println("hoge"); } } } lIPHFz͕ճ͚ͩग़ྗ͞ΕΔ Կ΋ى͖ͳ͍ ίϯύΠϧΤϥʔ ࣮ߦ࣌Τϥʔ
  20. ղઆ public class Sample { public static void main(String... args)

    { while (false) { System.out.println("hoge"); } } } 6OSFBDIBCMFDPEF
  21. ୈ໰

  22. ୈ໰Λ౿·͑ͯ public class Sample { public static void main(String... args)

    { while (false) { System.out.println("hoge"); } } }
  23. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { do { System.out.println("hoge"); } while (false); } }
  24. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { do { System.out.println("hoge"); } while (false); } } lIPHFz͕ճ͚ͩग़ྗ͞ΕΔ Կ΋ى͖ͳ͍ ίϯύΠϧΤϥʔ ࣮ߦ࣌Τϥʔ
  25. ࣍ͷίʔυͷಈ͖͸Ͳ͏ͳΔʁ public class Sample { public static void main(String... args)

    { do { System.out.println("hoge"); } while (false); } } lIPHFz͕ճ͚ͩग़ྗ͞ΕΔ Կ΋ى͖ͳ͍ ίϯύΠϧΤϥʔ ࣮ߦ࣌Τϥʔ
  26. public class Sample { public static void main(String... args) {

    do { System.out.println("hoge"); } while (false); } } ղઆ EPXIJMF͸ࣄޙධՁ ճॲཧͨ͠ޙʹ৚݅ࣜΛ൑ఆ
  27. ղઆ ॲཧ ৚ ݅ XIJMF ॲཧ ৚ ݅ EPXIJMF

  28. 0CKFDUJWF$ฤ

  29. ୈ໰

  30. Կ͕ग़ྗ͞ΕΔʁ

  31. Կ͕ग़ྗ͞ΕΔʁ if (@0) { NSLog(@"true"); } else { NSLog(@"false"); }

  32. Կ͕ग़ྗ͞ΕΔʁ if (@0) { NSLog(@"true"); } else { NSLog(@"false"); }

    USVF GBMTF
  33. Կ͕ग़ྗ͞ΕΔʁ if (@0) { NSLog(@"true"); } else { NSLog(@"false"); }

    USVF GBMTF
  34. ղઆ w @0͸</4/VNCFSOVNCFS8JUI*OU>ͷ4ZOUBY4VHBS w /4/VNCFS͸ΦϒδΣΫτ w ΦϒδΣΫτͱͯ͠͸ଘࡏ͢ΔͨΊɺ
 USVFͱͯ͠൑ఆ͞ΕΔ w @NO΋ಉ༷

  35. ୈ໰

  36. Կ͕ग़ྗ͞ΕΔʁ

  37. Կ͕ग़ྗ͞ΕΔʁ [ "hoge", "fuga", null, "foo", "bar" ] TBNQMFKTPO NSArray

    *array = ... // JSONΛಡΈࠐΉॲཧ if (array[2]) { NSLog(@"true"); } else { NSLog(@"false"); }
  38. Կ͕ग़ྗ͞ΕΔʁ USVF GBMTF [ "hoge", "fuga", null, "foo", "bar" ]

    TBNQMFKTPO NSArray *array = ... // JSONΛಡΈࠐΉॲཧ if (array[2]) { NSLog(@"true"); } else { NSLog(@"false"); }
  39. Կ͕ग़ྗ͞ΕΔʁ USVF GBMTF [ "hoge", "fuga", null, "foo", "bar" ]

    TBNQMFKTPO NSArray *array = ... // JSONΛಡΈࠐΉॲཧ if (array[2]) { NSLog(@"true"); } else { NSLog(@"false"); }
  40. ղઆ w /4"SSBZ౳ͷίϨΫγϣϯʹ͸OJMΛೖΕΔ͜ͱ͕Ͱ͖ͳ ͍ w େମखஈͱͯ͠/4/VMMͱ͍͏ΫϥεΛ࢖͏ w ͜ͷ࣌BSSBZ<>͔ΒऔΓग़͞ΕΔͷ͸</4/VMMOVMM>ͱ͍͏ γϯάϧτϯΦϒδΣΫτ w

    ΦϒδΣΫτͳͷͰUSVFͱͯ͠൑ఆ͞ΕΔ
  41. /4/VMMͱOJM NSLog(@"%@", nil); // -> (null) NSLog(@"%@", [NSNull null]); //

    -> <null> ഑ྻʹฆΕ͍ͯΔOVMM͸Α͘ݟམͱ͕ͪ͠
  42. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ

  43. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ w +BWB w 0$+1 0SBDMFೝఆࢿ֨ Ͱ͜͏͍͏໰୊͕ग़୊͞ΕΔ w ࣮຿Ͱ࢖͏ҙຯ͸໓ଟʹແ͍͕ɺ
 ϨΨγʔͳγεςϜͰۃكʹฆΕࠐΜͰΔ

    w Ϧʔμϒϧίʔυͬͯ஌ͬͯΔʁ
  44. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ w 0CK$ w ҙ֎ͱݟམͱ͕ͪ͠ w ͜ͷखͷޡղ͔ΒੜͣΔόά͕࣮ࡍʹ͋ͬͨ w 4XJGU΁ͷϦϓϨʔεͰ૝ఆͱҧ͏ಈ͖Λ͢Δͱ͔ w

    ಛʹ഑ྻʹฆΕࠐΉOVMM໰୊͸͋Δ͋Δ
  45. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ w ͍ͭͰʹ w ৽ਓݚमͰυϠΕΔ

  46. ·ͱΊ w ϨΨγʔݴޠͷཧղ͸ϦϓϨʔεͷڧ͍ຯํ w ࢥΘ͵όάΛੜ·ͳ͍ͨΊʹ΋ݴޠ࢓༷ͷཧղ͸େ੾ w ࣮຿Ͱ࢖Θͳ͍஌͔ࣝͩΒͬͯܰࢹ͠ͳ͍Α͏ʹ

  47. ྑ͍͓೥Λʂ✋