전체 글
-
20240826 10일차카테고리 없음 2024. 8. 26. 17:25
[String 클래스]String 객체의 문자열을 수정하는 것은 내부적으로는 수정된 문자열을 포함하는 새로운 String 객체를 만드는 것문자열 내용을 자주 변경한다면, String 클래스를 사용하는 것은 좋지 않음[StringBuffer, StringBuilder 클래스]변경될 수 있는 문자열을 다루기 위한 클래스다중 스레드 환경에서 StringBuffer 클래스가 안전함다중 스레드 환경이 아니라면 StringBuilder 클래스를 사용하는 것이 효율적임[System 클래스]가비지를 수거하는 순서는 객체의 생성 순서와는 무관[Singleton 패턴]애플리케이션 전체에서 단 1개의 객체만 생성해서 사용하려고 할 때 사용생성자를 private 접근 제한 → 외부에서 new 연산자로 생성자 호출 불가 [프로..
-
읽어볼만한 글카테고리 없음 2024. 8. 24. 17:39
https://brunch.co.kr/@topasvga/1969 데이터 직군 IoT개발자는 어떤 일을 하는가? 어떤 걸 공부해야 하나? 서비스 구성도로 확인 공부해야 할 기술? 어떻게 공부하면 좋을까요? 직종과 공부 자료 (코딩) 분" data-og-host="brunch.co.kr" data-og-source-url="https://brunch.co.kr/@topasvga/1969" data-og-url="https://brunch.co.kr/@topasvga/1969" data-og-image="https://scrap.kakaocdn.net/dn/F9JOs/hyWSf0CokQ/8xHM8CXKXF0V9ed9Ly9Fn0/img.jpg?width=1080&height=1173&face=0..
-
20240823 9일차카테고리 없음 2024. 8. 23. 17:26
[추상 클래스]객체를 생성할 수 있는 클래스 (실체 클래스)들의 공통적인 필드/메소드를 추출해서 선언한 클래스클래스가 설계도라면, 추상 클래스는 미완성 설계도선언: [접근지정자] abstract class [클래스 이름]new 연산자를 이용해서 객체를 직접 만들지 못함!!상속을 통해 자식 클래스만 만들 수 있음[추상 메서드]선언부만 있고 구현부가 없는 메서드추상 메소드 선언: abstract [return type] method_name (params);자식 클래스들의 공통 메소드를 뽑아서 추상 클래스로 작성할 때, 메소드 시그니처만 동일하고 메서드 내용은 자식 클래스마다 달라야 하는 경우가 많음추상 메소드는 메소드의 필요성만 알고, 아직 메소드의 내용을 모르기 때문에, 메소드 실행 내용인 중괄호 { }..
-
[Java] Arrays.sort( )를 이용한 객체 배열 정렬카테고리 없음 2024. 8. 23. 17:13
샘플 코드import java.util.Arrays;import java.util.Comparator;class Person { String name; int age; Person(String name, int age) { this.name = name; this.age = age; } @Override public String toString() { return name + ": " + age; }}public class Main { public static void main(String[] args) { Person[] people = { new Person("Alice", 30), ..
-
20240822 8일차카테고리 없음 2024. 8. 22. 16:52
[다형성] - 기본형의 형변환과 달리 참조형의 형변환은 2가지 타입으로 나뉨 1) upcasting (child 타입 -> parent 타입) - parent 클래스의 정보는 이미 child 클래스가 전부 가지고 있기 때문에 별도의 형변환이 필요 없음 (자동 형변환) - child와 parent의 공통된 것만 사용 가능 - child 클래스 전용의 것은 사용 불가 - child 클래스의 정보를 담을 수 있는 객체에 parent 클래스의 자료형을 부여해서, parent 클래스처럼 사용하는 것 (기능이 제한됨) - upcasting 하고 메소드를 실행할때, 만일 child 클래스에서 오버라이딩한 메서드가 있을 경우, parent 클래스의 메서드가 아닌 오버라이딩 된 메서드가 실행됨!!! (동적 바인딩, 런타..
-
[Java] 생성자카테고리 없음 2024. 8. 22. 14:27
자식 클래스의 생성자에서는 반드시 부모 클래스의 생성자를 호출해야한다자식 클래스가 부모 클래스를 상속 받을 때, 부모 클래스의 field와 method를 포함한 메모리 구조를 초기화 해야되기 때문이다부모 생성자를 호출하는 방식에는 2가지가 있다자동 호출: 자식 클래스의 생성자에서 명시적으로 부모 클래스의 생성자를 호출하지 않으면, 자바 컴파일러가 자동으로 부모 클래스의 기본 생성자를 호출하는 것명시적 호출: 자식 클래스의 생성자에서 super() 키워드를 사용하여 특정 부모 클래스 생성자를 호출하는 것 자동 호출public class Main { public static void main(String[] args) { Child child = new Child(); }}class Parent {..
-
20240821 7일차카테고리 없음 2024. 8. 21. 17:28
[IntelliJ 단축키] - 껍데기만 선언한 함수 이름 클릭 후 Alt + Enter: 아직 구현안한 함수를 만들어줌 - 블록 선택하고 Ctrl + Alt + T: 해당 블록을 surround with 할 수 있는 옵션 표시 (ex. while loop, try-catch, ...) - Ctrl + O: override 단축키 [가변 개수 인수] - 메서드에 데이터 타입이 같은 가변 개수의 인수를 전달 가능 - 사용법: 데이터타입 ... 변수 - 예시: int... v - 1개의 가변 개수 매개변수만 사용 가능 - 가변 개수 매개변수는 마지막에 위치 - 가변 개수 인수를 가진 메서드를 호출하면 내부적으로 배열을 생성하여 처리 [열거 타입 (enum)] - 관련된 상수들을 같이 묶어 놓은 것 - Java..