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

Trap Questions in Java and Obj-C

417.72KI
December 03, 2019

Trap Questions in Java and Obj-C

417.72KI

December 03, 2019
Tweet

More Decks by 417.72KI

Other Decks in Programming

Transcript

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

    View full-size slide

  2. 4XJGUͱ,PUMJO

    View full-size slide

  3. 4XJGUͱ,PUMJO

    View full-size slide

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

    View full-size slide

  5. ͳΜͰࠓ͞Β+BWB0CK$

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. ͱ͍͏͜ͱͰ

    View full-size slide

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

    View full-size slide

  11. w 5BLVIJSP.VUBBLB௣໊Նر ,*

    w 4&೥ 8FC J04 "OESPJE ৽ਓݚमߨࢣFUD

    J04 डୗ։ൃ
    ೥൒

    J04 ࣗࣾ։ൃ
    ࠓίί
    w 5XJUUFS 2JJUB@LJ

    (JU)VC,*
    w 4XJGUѪ޷ձࢀՃप೥

    ΋͏΍ΜΧϨʔ͸೥໨
    ͓લ୭Α

    View full-size slide

  12. #VJME$POpHTXJGU
    ελʔ͍ͩ͘͞

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  18. ղઆ
    public class Sample {
    public static void main(String... args) {
    while (false) {
    System.out.println("hoge");
    }
    }
    } 6OSFBDIBCMFDPEF

    View full-size slide

  19. ୈ໰Λ౿·͑ͯ
    public class Sample {
    public static void main(String... args) {
    while (false) {
    System.out.println("hoge");
    }
    }
    }

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. public class Sample {
    public static void main(String... args) {
    do {
    System.out.println("hoge");
    } while (false);
    }
    }
    ղઆ
    EPXIJMF͸ࣄޙධՁ ճॲཧͨ͠ޙʹ৚݅ࣜΛ൑ఆ

    View full-size slide

  24. ղઆ
    ॲཧ

    ݅
    XIJMF
    ॲཧ

    ݅
    EPXIJMF

    View full-size slide

  25. 0CKFDUJWF$ฤ

    View full-size slide

  26. Կ͕ग़ྗ͞ΕΔʁ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  30. ղઆ
    w @0͸4/VNCFSOVNCFS8JUI*OU>ͷ4ZOUBY4VHBS
    w /4/VNCFS͸ΦϒδΣΫτ
    w ΦϒδΣΫτͱͯ͠͸ଘࡏ͢ΔͨΊɺ

    USVFͱͯ͠൑ఆ͞ΕΔ
    w @NO΋ಉ༷

    View full-size slide

  31. Կ͕ग़ྗ͞ΕΔʁ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  35. ղઆ
    w /4"SSBZ౳ͷίϨΫγϣϯʹ͸OJMΛೖΕΔ͜ͱ͕Ͱ͖ͳ
    ͍
    w େମखஈͱͯ͠/4/VMMͱ͍͏ΫϥεΛ࢖͏
    w ͜ͷ࣌BSSBZ<>͔ΒऔΓग़͞ΕΔͷ͸4/VMMOVMM>ͱ͍͏
    γϯάϧτϯΦϒδΣΫτ
    w ΦϒδΣΫτͳͷͰUSVFͱͯ͠൑ఆ͞ΕΔ

    View full-size slide

  36. /4/VMMͱOJM
    NSLog(@"%@", nil); // -> (null)
    NSLog(@"%@", [NSNull null]); // ->
    ഑ྻʹฆΕ͍ͯΔOVMM͸Α͘ݟམͱ͕ͪ͠

    View full-size slide

  37. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ

    View full-size slide

  38. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ
    w +BWB
    w 0$+1 0SBDMFೝఆࢿ֨
    Ͱ͜͏͍͏໰୊͕ग़୊͞ΕΔ
    w ࣮຿Ͱ࢖͏ҙຯ͸໓ଟʹແ͍͕ɺ

    ϨΨγʔͳγεςϜͰۃكʹฆΕࠐΜͰΔ
    w Ϧʔμϒϧίʔυͬͯ஌ͬͯΔʁ

    View full-size slide

  39. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ
    w 0CK$
    w ҙ֎ͱݟམͱ͕ͪ͠
    w ͜ͷखͷޡղ͔ΒੜͣΔόά͕࣮ࡍʹ͋ͬͨ
    w 4XJGU΁ͷϦϓϨʔεͰ૝ఆͱҧ͏ಈ͖Λ͢Δͱ͔
    w ಛʹ഑ྻʹฆΕࠐΉOVMM໰୊͸͋Δ͋Δ

    View full-size slide

  40. ͜ΜͳΜ஌ͬͯͯԿʹͳΔʁ
    w ͍ͭͰʹ
    w ৽ਓݚमͰυϠΕΔ

    View full-size slide

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

    View full-size slide

  42. ྑ͍͓೥Λʂ✋

    View full-size slide