๐ ์๋ฐ Java25 ์๋ฐ(JAVA) - ์ด๊ธฐํ์ ์์ฑ์ Constructor Constructor : ์์ฑ์ ํจ์ ํด๋์ค๋ช ๊ณผ ๊ฐ๋ค return๊ฐ์ด ์๋ค. Over Load๊ฐ ๊ฐ๋ฅํ๋ค. class ์์ฑ์์ ์๋ํธ์ถ ๋ณ๋์ ํธ์ถ์ด ๋ถ๊ฐ๋ฅ ์ด๊ธฐํ ์๋๋ค ์๋ต์ด ๊ฐ๋ฅํ๋ค 1. ๋ฆฌํด๊ฐ์ด ์๋ค. ์์ฑ์๋ ์ธ์คํด์ค๋ฅผ ์์ฑํด์ฃผ๋ ์ญํ ์ ํ๋ ํน์ํ ๋ฉ์๋๋ผ๊ณ ํ ์ ์๋ค. ๊ทธ๋ฐ๋ฐ ๋ฐํ ๊ฐ์ด ์๋ค๋ฉด ์๋ฑํ ๊ฐ์ฒด๊ฐ ์์ฑ๋ ๊ฒ์ด๋ค. ๋ฐ๋ผ์ ๋ฐํ ๊ฐ์ ํ์๋กํ๋ ์์ ์์๋ ์์ฑ์๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค. ๋ฐํ ๊ฐ์ด ์๊ธฐ ๋๋ฌธ์ return๋ ์ฌ์ฉํ์ง ์๊ณ , ๋ฐํ ๊ฐ์ ๋ฉ์๋ ์ ์์ ํฌํจ์ํค์ง๋ ์๋๋ค. 2. ์์ฑ์์ ์ด๋ฆ์ ํด๋์ค์ ์ด๋ฆ๊ณผ ๊ฐ๋ค. ์๋ฐ์์ ํด๋์ค์ ์ด๋ฆ๊ณผ ๋์ผํ ๋ฉ์๋๋ ์์ฑ์๋ก ์ฌ์ฉํ๊ธฐ๋ก ์ฝ์๋์ด ์๋ค. 12345678910111213141516171819202122232425262728.. 2021. 1. 27. ์๋ฐ(JAVA) - ๋ ์ฃผ์ฌ์ ํฉ ๋ง์ถ๊ธฐ, ๋ฒ ํ ๊ฒ์ 123456789101112 public class MainClass { public static void main(String[] args) { // TODO Auto-generated method stub GamePlay gp = new GamePlay (); gp.gamePlay(); } }Colored by Color Scriptercs 123456789101112131415public class Dice { private int number; public void diceRandom() { number = (int)(Math.random()*6)+1; } public int getNumber() { return number; } } Colored by Color Scriptercs 1234567.. 2021. 1. 26. ์๋ฐ(JAVA) - TV ์ ์, ๋ณผ๋ฅจ, ์ฑ๋ ๋ฆฌ๋ชจ์ปจ ํ๋ก๊ทธ๋๋ฐ 123456789101112131415161718192021 public class MainClass { public static void main(String[] args) { Mytv2 t = new Mytv2(); t.setChannel(10); System.out.println("CH:" + t.getChannel()); t.setVolume(20); System.out.println("VOL" + t.getVolume()); } } Colored by Color Scriptercs 123456789101112131415161718192021222324252627282930313233343536373839public class Mytv2 { private boolean isPowerOn; priv.. 2021. 1. 26. ์๋ฐ(JAVA) - ํ์ ์ฑ์ ๊ฐ์ฒดํ ํ๋ก๊ทธ๋๋ฐ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import java.util.Scanner; public class Student { Scanner sc = new Scanner(System.in); String name; //ํ์์ด๋ฆ int ban; //๋ฐ int no; //๋ฒํธ int kor; //๊ตญ์ด์ ์ int eng; //์์ด์ ์ int math; //์ํ์ ์ int getTotal() { return kor + eng + math;} float getAverage() { return (((getTotal()*100/3+5)/10)/10f); } } Colored by Color Scripter cs 1 2 3 4 5 6 7 8 9 10 11 12.. 2021. 1. 26. ์ด์ 1 2 3 4 5 6 7 ๋ค์