Javaࣈࣞࢡ࣐ࣚࣤࢡ ᇱᮇࢸ࣭ࢰᆵࠉ ฝງ ࢹࣚࣤ ᇱᮇࢸ࣭ࢰᆵࠉንᩐ࠽ࡻࡦᏽᩐ ᇱᮇࢸ࣭ࢰᆵࡡ࢛ࣇࢩ࢘ࢠࢹᆵ ฝງ ⦆⩞ၡ㢗 Javaࣈࣞࢡ࣐ࣚࣤࢡ 2 ᇱᮇࢸ࣭ࢰᆵ㸯㸦 రࡿࡡࢸ࣭ࢰᆵࡢࠉࠔථࡿ⟵ࠕࡡࠔྞᮈࠕ࡚⾪♟ ࡊࡄࡿࡣࡽࡱࡎࢆ ථࡿ⟵ࡡೋࡡን࠻ࡼࡿࡾࡵࡡࡢࠔንᩐࠕ࡛࠷࠷ࠉ ೋࡡን࠻ࡼࡿ࠷ࡵࡡࡢࠔᏽᩐࠕ࡛࠷࠷ࡱࡌ ࢸ࣭ࢰᆵ ྞᮈ Javaࣈࣞࢡ࣐ࣚࣤࢡ 3 ᇱᮇࢸ࣭ࢰᆵ㸯㸧 ንᩐࡵᏽᩐࡵࠉࡐࡡೋࢅ⏕ࡌࡾ๑࡞ルᙔࡡྞ๑ ࢅᐃゕࡊࡄࡿࡣࡽࡱࡎࢆ ೋࡡ᭯⏕⠂ᅑࡢࠉᐃゕࡡన⨠࡞ࡻࡖ࡙ንࢂࡽࡱࡌ ࡆࡿ࠾ࡼࠉࡆࡿ࡛ࠉ…ࠉ ࡛ࡆࡿࢅ࠷ࡱࡌ Javaࣈࣞࢡ࣐ࣚࣤࢡ 4 ᩒᩐ㸯ንᩐ ༟⢥ᗐ㸝int㸞 ᭡ᘟ㸯intࠈንᩐྞ;ࠈࡱࡒࡢࠈintࠈንᩐྞ=ิೋ; ಶ⢥ᗐ㸝long㸞 ᭡ᘟ㸯longࠈንᩐྞ;ࠈࡱࡒࡢࠈlongࠈንᩐྞ=ิೋL; 32ࣄࢴࢹ int long 64ࣄࢴࢹ Javaࣈࣞࢡ࣐ࣚࣤࢡ 5 ᩒᩐ㸯ᏽᩐ ༟⢥ᗐ㸝int㸞 ᭡ᘟ㸯ᏽᩐࡡᐃゕ࡞ࡢfinalࢅintࡡ๑࡞ࡗࡄ࡙ࠉิೋ ࡢᚪࡍオථࡌࡾ ಶ⢥ᗐ㸝long㸞 long int ᭡ᘟ㸯ᏽᩐࡡᐃゕ࡞ࡢfinalࢅlongࡡ๑࡞ࡗࡄ࡙ࠉิ ೋࡢᚪࡍオථࡌࡾ -9,223,372,036,854,775,808ࠤ9,223,372,036,854,775,807 -2,147,483,648ࠤ+2,147,483,647 Javaࣈࣞࢡ࣐ࣚࣤࢡ 6 ᐁᩐ㸯ንᩐ ༟⢥ᗐ㸝float㸞 ᭡ᘟ㸯float ንᩐྞ;ࠈࡱࡒࡢ float ንᩐྞ=ิೋF; ಶ⢥ᗐ㸝double㸞 ᭡ᘟ㸯 double ንᩐྞ;ࠈࡱࡒࡢ double ንᩐྞ=ิೋD; 32ࣄࢴࢹ float double 64ࣄࢴࢹ Javaࣈࣞࢡ࣐ࣚࣤࢡ 7 ᐁᩐ㸯ᏽᩐ ༟⢥ᗐ㸝float㸞 ᭡ᘟ㸯ᏽᩐࡡᐃゕ࡞ࡢfinalࢅfloatࡡ๑࡞ࡗࡄ࡙ࠉิೋ ࡢᚪࡍオථࡌࡾ ಶ⢥ᗐ㸝double㸞 ᭡ᘟ㸯ᏽᩐࡡᐃゕ࡞ࡢfinalࢅdoubleࡡ๑࡞ࡗࡄ࡙ࠉิ ೋࡢᚪࡍオථࡌࡾ double ±4.9E-324ࠤ±1.7976931348623157E+308 float ±1.4E-35ࠤ±3.4028235E+38 Javaࣈࣞࢡ࣐ࣚࣤࢡ 8 ᩝᏊ㸝char㸞ᆵ ༟ୌࡡᩝᏊࡷโᚒࢤ࣭ࢺࡡ⾪♟➴࡞⏕࠷ࡱࡌ 16ࣄࢴࢹࡡࣗࢼࢤ࣭ࢺࡡୌᩝᏊ ᭡ᘟ㸯char ንᩐྞ ; ࡱࡒࡢ char ንᩐྞ = ‘\u0039’; ࣗࢼࢤ࣭ࢺ⾪ 㸝ୌ㒂㸞 Javaࣈࣞࢡ࣐ࣚࣤࢡ 9 ᩝᏊา㸝String㸞ᆵ Java࡚ࡢ≁ืన⨠ࡡࡵࡡ࡚ࠉን᭞⬗࢛ࣇ ࢩ࢘ࢠࢹࡡࢠࣚࢪ࡚ࡌ ࣒ࢮࢴࢺࡢኣࡂࡡࡒࡴࠉᩅ⛁᭡ࡡ1.7⟿ࢅཤ↯ Javaࣈࣞࢡ࣐ࣚࣤࢡ 10 ࣇ࣭ࣜ㸝boolean㸞ᆵ ึᏽ࡞⏕࠷ࡾࢸ࣭ࢰ ┷㸝true㸞ࠉ࠽ࡻࡦഅ㸝false㸞ࡡೋࡊ࠾࡛ࡿ࠷ ᭡ᘟ㸯boolean ንᩐྞ; ࡱࡒࡢ boolean ንᩐྞ=ೋ; Javaࣈࣞࢡ࣐ࣚࣤࢡ 11 ࣁࢹ㸝byte㸞ᆵ ᩒᩐᆵࡡࢸ࣭ࢰࢅ⾪ࡌ࡞ࡢ⏕ࡈࡿࡱࡌ ᩒᩐࡡᄿฦࡡୌࡡࣄࢴࢹᩐࡊ࠾⏕ࡊ࠷ࡒࡴࢨ ᑚᐖ㔖ࣈࣞࢡ࣑ࣚ࡞ࡻࡂ⏕࠷ࡼࡿࡱࡌ ᭡ᘟ㸯byte ንᩐྞ; ࡱࡒࡢ byte ንᩐྞ = ೋ; byte -128ࠤ127 Javaࣈࣞࢡ࣐ࣚࣤࢡ 12 ࢨ࣭ࣘࢹ㸝short㸞ᆵ ᩒᩐᆵࡡࢸ࣭ࢰࢅ⾪ࡌ࡞ࡢ⏕ࡈࡿࡱࡌ ㏳ᖏࡡᩒᩐࡡ༖ฦࡊ࠾ࡡࣄࢴࢹᩐࢅ⏕ࡌࡾࡒࡴ ࡞ࢨ࣭ࣘࢹࡡྞࡄࡼࡿࠉཚࡊ࠷ᐖ㔖โ㝀୕ࡡ スゝ࡞ࡢࡻࡂ⏕࠷ࡼࡿࡱࡌ ᭡ᘟ㸯 short -32,768ࠤ32,767 Javaࣈࣞࢡ࣐ࣚࣤࢡ 13 ᇱᮇࢸ࣭ࢰᆵࡡ࢛ࣇࢩ࢘ࢠࢹ ࡡᇱᮇࢸ࣭ࢰᆵ࡞ᑊᚺࡌࡾ࢛ࣇࢩ࢘ࢠࢹᏋᅹ ࡊࡱࡌ㸝ᩅ⛁᭡ࡡ1.3⟿ࢅཤ↯㸞 ᇱᮇ ࢸ࣭ࢰ ᆵ byte Byte short Short Int int long Long float double Float ࢛ࣇࢩ࢘ࢠࢹ ᆵ Double char Char String Javaࣈࣞࢡ࣐ࣚࣤࢡ 14 ࡐࡡࡡࢸ࣭ࢰ㸝ᏽᩐ㸞 ᐁᩐ࡚ࡢࠉ Ѹ҄㸝Float.NEGATIVE_INFINITY࠽ࡻࡦ Double.NEGATIVE_INFINITY㸞 +҄㸝Float.POSITIVE_INFINITY࠽ࡻࡦ Double.POSITIVE_INFINITY㸞 ☔ᏽ⬗㸝ౚ㸯҄҄㸞ࡡ㸝Float.NaN࠽ࡻࡦ Double.NaN㸞࠵ࡾ Javaࣈࣞࢡ࣐ࣚࣤࢡ 15 ᇱᮇࢸ࣭ࢰ࡛࢛ࣇࢩ࢘ࢠࢹࡡ㐢࠷ String௧አࡡᇱᮇࢸ࣭ࢰࡡንᩐ㸝ᏽᩐ㸞ࡢೋࢅ ࡵࡖ࡙࠷ࡂ࡙ࡵルᙔࡡࢸ࣭ࢰᆵ࡞ᑊࡌࡾさ㡷 ⏕ណࡈࡿࡾ ࢛ࣇࢩ࢘ࢠࢹࢅᣞࡊ♟ࡌንᩐࡢ࢛ࣇࢩ࢘ࢠࢹ new࡚⏍ᠺࡈࡿࡾ࡛࢛ࣇࢩ࢘ࢠࢹ࡞ᚪさᐖ㔖ࢅ ᣞࡊ♟ࡌࡻ࠹࡞ࡾ Javaࣈࣞࢡ࣐ࣚࣤࢡ 16 …㐢࠷㸯ࡡᴣᛍᅒ ௧ୖࡡࡻ࠹࡞⾪⌟࡚ࡀࡾ㸝ౚ㢗ࣈࣞࢡ࣑ࣚࢅཤ ↯㸞 int i; int j=3; Junior j1; Junior j2 = new Junior(); i j1 j j2 Javaࣈࣞࢡ࣐ࣚࣤࢡ 17 㸝❻ᮆࡡ㸞ฝງ ࡞ౚ㢗࡚ࡢ❻ᮆࡡฝງࡢౚ♟ࡈࡿ࡙࠷ࡱࡌ ᭡ᘟࡢ㸯System.out.println(⾪♟ࡌࡾࢸ࣭ࢰ➴); ࠵ࡾ࠷ࡢࠉᨭ⾔ࢅ᭩ᚃ࡞ࡗࡄ࠷ሔྙࡢ System.out.print(⾪♟⏕ࢸ࣭ࢰ); ንᩐࡡೋࢅฝງࡈࡎࡒ࠷࡛ࡀࡢࠉንᩐྞࢅオ㏑ࡊ ࡱࡌࠊฝງࡡࡡ㒂ฦ࡛ࡗࡃࡒࡴ࡞ࠔ㸠ࠕࡡ㏻ ⤎ⁿ⟤Ꮔ㸝ᩝᏊ࡛ᩝᏊࢅྙెࡌࡾࡵࡡ㸞ࢅ⏕ࡊ ࡱࡌ ౚ㸯System.out.print(“value = ”+ i); Javaࣈࣞࢡ࣐ࣚࣤࢡ 18 ࢛ࣇࢩ࢘ࢠࢹࡡࢸ࣭ࢰࡡฝງ ࢛ࣇࢩ࢘ࢠࢹࡡࢠࣚࢪ࡞toStringࡡ࣒ࢮࢴࢺࢅ⏕ ណࡌࡿࡣࠉࡐࡆ࡞᭡࠾ࡿ࡙࠷ࡾ㏳ࡽࠉ≁ᏽࡡࢸ࣭ ࢰࢅฝງࡈࡎࡾࡆ࡛࡚ࡀࡾ System.out.println(j1); Javaࣈࣞࢡ࣐ࣚࣤࢡ 19 ᐁ⩞㸯(ࣈࣞࢩ࢘ࢠࢹྞ=Ꮥ⡘␊ྒ) ᅂࡡ᭩ᚃࡡౚ㢗ࢅ⥽㞗ࡊ࡙㸨ᖳḗ(Junior)ࡡḗ ࡡࢸ࣭ࢰࢅಕᣚ࡚ࡀࡾࡻ࠹࡞ルᙔࡡࢠࣚࢪࢅን ᭞ࡊࡈ࠷ࠊ ⏍ᖳ᭮(birthdate) 㞹リ␊ྒ(telephone) ⱉᏊ(surname) ᩺ࢸ࣭ࢰࡡスᏽ⏕(set…())࠽ࡻࡦㄖࡲฝࡊࡻ࠹ (get…())ࡡ࣒ࢮࢴࢺࡵຊ࠻ࡈ࠷ Javaࣈࣞࢡ࣐ࣚࣤࢡ 20
© Copyright 2024 ExpyDoc