1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
class A { int A = 999; A() { System.out.println("111"); } A(int num) { System.out.println("222"); } static { System.out.println("000"); } int A() { System.out.println("333"); return A; } void A(int A) { System.out.println("444"); this.A = A; } void A(A A) { System.out.println("555"); this.A = A.A; } } public class Java_107_03_21 { public static void main(String[] args) { // TODO 自動產生的方法 Stub A a = new A(); a = new A(1); a.A(); a.A(999); a.A(a); System.out.println(a.A); } } |
日期: 2018 年 3 月 26 日
Java 2018-03-14 HW
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
class S45 { int quan; String taste, temp; S45() { this(1); SOP("AAA"); } S45(int a) { this(1, ""); SOP("BBB"); } S45(int a, String b) { SOP("CCC"); } public void buyjuice() { SOP("要買什麼果汁:"); } public void buyjuice(String taste) { SOP(String.format("1杯%s汁", taste)); } public void buyjuice(int quan, String taste) { SOP(String.format("%d杯%s汁", quan, taste)); } public void buyjuice(String temp, String taste) { SOP(String.format("1杯%s的%s汁", temp, taste)); } public void buyjuice(int quan, String temp, String taste) { SOP(String.format("%d杯%s的%s汁", quan, temp, taste)); } private void SOP(String str) { System.out.println(str); } } public class Java_107_03_14_HW1 { public static void main(String[] args) { // TODO 自動產生的方法 Stub S45 s45 = new S45(); s45.buyjuice(); s45.buyjuice("蘋果"); s45.buyjuice(2, "蘋果"); s45.buyjuice("冰", "蘋果"); s45.buyjuice(3, "冰的", "蘋果"); } } |
Java 2018-03-07 HW
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import java.text.DecimalFormat; import java.util.Scanner; public class Java_107_3_7_HW1 { public static void main(String[] args) { // TODO 自動產生的方法 Stub Scanner scanner = new Scanner(System.in); int members[][] = new int[5][3]; int input; double chi = 0, eng = 0, math = 0; for (int i = 0; i < members.length; i++) { for (int j = 0; j < members[i].length; j++) { input = scanner.nextInt(); members[i][j] = input; if (j == 0) chi += input; if (j == 1) eng += input; if (j == 2) math += input; } } System.out.println("NO\tChinese\tEnglish\tMathematic"); System.out.println("===================================="); for (int i = 0; i < members.length; i++) { System.out.print(i + 1); for (int j = 0; j < members[i].length; j++) { System.out.print("\t" + members[i][j]); } System.out.println(""); } chi /= members.length; eng /= members.length; math /= members.length; System.out.println("===================================="); DecimalFormat df = new DecimalFormat("0.00"); System.out.print(String.format("Average\t%s\t%s\t%s", df.format(chi), df.format(eng), df.format(math))); } } |