Language

Language/JAVA
📍 24.04.11(목) ~ 24.04.12(금) : 상속, 오버라이딩, IS-A/HAS-A 관계, 다형성, package/import/접근제어자, 추상클래스, 인터페이스, try ~ catch ~ finally, throws, Thread📍 24.04.22(월) ~ 24.04.26(금) : singleton, enum, generic 📍 24.04.11(목) 12일차this / this() / super / super()this참조변수 ex) this.멤버변수, this.멤버메소드()this.멤버변수this.멤버메소드()this()생성자 호출 super참조변수super.부모의 멤버변수super.부모의 멤버메소드()super()부모의 생성자 호출 ..
Language/JAVA
public class ParameterQuiz { public static String concat(String ... args) { // 초기값 설정 String reslut = ""; for (String ar: args) { reslut += ar; } return reslut; } public static void main(String[] args) { String[] one = {"하나", "둘", "셋"}; System.out.println(concat(one)); // 하나둘셋 // "넷", "다섯", "여섯 System.out.println(concat("넷", "다섯", "여섯")); // 넷다섯여섯 } }
Language/JAVA
내부 접근 : 객체 안에서 돌 때 외부 접근 : 외부에서 접근할 때 class Student { // field : 필드, 멤버변수 int age; String name; // constructor Student(int age, String name) { this.age = age; this.name = name; } // method void showInfo() { System.out.println("나이 : " + this.age); System.out.println("이름 : " + this.name); } } public class ArrayEx02 { public static void main(String[] args) { // 객체 배열 : 1차원 배열 // 타입[] 배열명 = new 타입[길..
Language/JAVA
public class ArrayEx03CleanCode { public static void main(String[] args) { // [ 1차원 배열 ] 길이가 1개인 배열 // 자료형[] 참조변수 = new 자료형[열길이]; // 자료형[] 배열명 = new 자료형[열길이]; //int[] arr = new int[5]; int[] arr = new int[] {1, 3, 5, 7, 9}; System.out.println("arr >> " + arr + "\n"); // [ 2차원 배열 ] 길이가 2개인 배열 // 배열 생성과 동시에 초기화 // int[][] arr2 = new int[2][3]; int[][] arr2 = {{2, 3, 4},{8}}; // 2. 값 설정 //arr2[0][0..
Language/JAVA
public class ArrayEx03 { public static void main(String[] args) { // [ 1차원 배열 ] 길이가 1개인 배열 int[] arr = new int[5]; // 자료형[] 참조변수 = new 자료형[열길이]; System.out.println("arr >> " + arr); // [ 2차원 배열 ] 길이가 2개인 배열 int[][] arr2 = new int[2][4]; // 자료형[][] 참조변수 = new 자료형[행길이][열길이]; System.out.println("arr2 >> " + arr2); // 2차원 배열의 참조변수 // arr2 : 참조변수 - 행의 시작 주소 // arr2[0]: 참조변수 - 첫 번째 1차원 배열의 시작 주소 // ar..
Language/JAVA
class Student { // field : instance field int age; String name; // constructor Student() {} Student(int age) { this.age = age; } // setter void setAge(int age) { this.age = age; } void showInfo() { System.out.println("나이 >> " + age); } } public class ConstructorEx01 { public static void main(String[] args) { // 홍길동 객체(인스턴스) 생성 System.out.println("** 홍길동 학생 정보 **"); Student hong = new Student(25)..
Language/JAVA
class Robot { // instance field int year = 2000; // 기본값 2000년 String name = "없음"; // 기본값 없음 String company = "없음"; // 기본값 없음 // constructor Robot () { // 하나라도 생성자 호출하면 기본값을 설정해줘야함 } Robot (int year) { this.year = year; } Robot (String str) { if (str == "페퍼") { this.name = str; } else if (str == "aa") { this.name = str; } else if (str == "메가봇"){ this.company = str; } } Robot (int year, String nam..
Language/JAVA
// class 정의 ========================================== class Customer { // 멤버 변수 int id; String name; // 멤버 메소드 public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } void showInfo() { System.out.printf("ID : %d, NAME : %s\n", id, name ); } } // =================================..
print(blue)