기록
-
학원 DAY20. Date, Calendar, Format, Math 클래스기록 2022. 10. 4. 01:21
Date클래스 시스템의 현재 날짜와 시간정보를 표현하는 클래스다. java.util 패키지에 있다. 주요 생성자 new Date() 현재 날짜와 시간정보가 포함된 객체가 생성된다. new Date(long unixTime) 지정된 유닉스타임에 해당하는 날짜와 시간정보가 포함된 객체가 생성된다. // 시스템의 현재 날짜정보와 시간정보가 포함된 Date객체가 생성된다. Date now = new Date(); // 지정된 유닉스타임(long값)에 해당하는 날짜와 시간정보가 포함된 객체가 생성된다. Date date = new Date(0); 주요 메소드 boolean after(Date when) 지정된 날짜보다 이후 날짜인지 확인한다. boolean before(Date when) 지정된 날짜보다 이전 날..
-
학원 DAY19. Wrapper 클래스기록 2022. 10. 3. 22:52
- 기본자료형 값을 담은 객체를 생성하는 클래스다. - java.lang패키지에 정의되어 있다. ex. Integer x = new Integer(10); // x라는 변수에는 주소값이 들어있으며, Integer객체에 멤버변수의 이름은 모르지만 10이라는 값이 들어있다는 의미이다. 즉, Integer라는 객체는 정수값10을 갖고 있는 객체이다. 사용해야 할 때 : 기본자료값이 아닌 객체로 저장해야 할 때 (자바의 자료구조 안에는 기본자료형을 담을 수 없고 객체만 담을 수 있다.) 호출할 메소드의 매개변수가 객체를 요구할 때 null값이 저장될 가능성이 있을 때 (기본자료형은 null값을 저장할 수 없다.) 해당 기본자료형값에 대한 다양한 기능을 실행해야 할 때 각각의 기본자료형마다 대응되는 Wrapper..
-
학원 DAY18. System 클래스기록 2022. 10. 3. 21:53
System 클래스 - 자바실행환경이 설치된 시스템(컴퓨터)에 대한 유용한 값과 시스템과 연결된 입출력 객체를 제공하는 클래스다. - java.lang 패키지에 속해있다. - System 클래스의 모든 필드와 모든 메소드는 정적필드, 정적메소드다. (객체 생성없이 사용 가능) System 클래스에서 제공하는 것 ▶ 표준입력장치, 표준출력장치, 표준에러출력장치와 연결된 스트림 static InputStream System.in; // System.in이라는 변수안에는 InputStream이라는 객체가 들어있는 것이다. - 표준 입력장치(키보드)와 연결된 객체를 제공한다. static PrintStream System.out; // System.out이라는 변수안에는 PrintStream이라는 객체가 들어있..
-
학원 DAY17. StringBuilder, StringBuffer 클래스기록 2022. 10. 3. 19:23
- String과는 상관없고 캐릭터를 순서대로 담고 있는 객체이다. - 내부저장소(버퍼)를 갖고 있다. - 기존의 "+"연산을 사용한 문자열 이어붙이기에서 문자열은 불변객체이기 때문에 기존 문자열은 그대로 메모리에 남아있고, 새로운 객체를 만든다. 따라서, 불필요한 String객체의 생성으로 인하여 메모리 부족 현상이 발생할 수 있다는 문제점이 있다. 이를 해결하기 위해 StringBuilder, StringBuffer가 있는 것이다. - StringBuilder객체 내부저장소에 값들을 순서대로 저장할 수 있다. - append()메소드를 사용하여 String객체를 매번 새로 생성하지 않고 임시저장소(버퍼)에 데이터를 순서대로 저장할 수 있다. -..
-
학원 DAY 17. String 클래스기록 2022. 10. 3. 17:30
String 클래스 문자열을 표현하는 객체. (문자열은 문자를 연이어 늘어놓은 것을 의미하므로 문자배열인 char배열과 같은 뜻이다. 그런데, 자바에서는 char배열이 아닌 String클래스를 이용해서 문자열을 처리하는 이유는 String클래스가 char배열에 여러가지 기능을 추가하여 확장한 것이기 때문이다. char배열을 사용하는 것보다 String클래스를 사용하는 것이 문자열을 다루기 더 편리하다. [출처] 자바의 정석 기초편) 문자열은 불변객체다. 한번 생성된 문자열은 절대로 변하지 않는다. (문자열은 읽을 수만 있을 뿐 내용을 변경할 수 없다. 변경가능한 문자열을 다루려면 StringBuffer클래스를 사용) String객체를 생성하는 방법 String s = "abc"; String s = ne..
-
학원 DAY 17. API, Object, 접근제한자기록 2022. 10. 2. 22:01
API(Application Programming Interface) 자바를 사용해서 어플리케이션을 쉽게 구현할 수 있도록 제공되는 라이브러리(클래스들의 집합) 자바에서는 입출력, 네트워크, 자료구조와 같이 어플리케이션 구현에 꼭 필요한 클래스를 구현해 놓은 것. 자바 API는 JDK(자바 개발 도구)설치시 같이 설치된다. 이클립스와 같은 통합개발환경에서 프로젝트를 생성하면 JAVA API를 바로 사용할 수 있도록 프로젝트의 클래스패스에 자동으로 등록시킨다. (classpath는 자바가상머신이 프로그램을 실행할 때 .class파일을 찾는 경로를 말함) 이클립스 왼쪽 창의 api에서 오른쪽버튼 build path > configure build path에 들어가면 api가 등록되어있음을 확인할 수 있다...
-
학원 DAY 16. 상속과 구현기록 2022. 10. 2. 21:20
* 부모클래스의 공개된 속성과 공개된 기능을 물려받는다. * 자식클래스를 빠르게 정의할 수 있다. * 같은 부모클래스를 상속받은 자식클래스는 전부 같은 부모타입으로 클래스 형변환이 가능하다. * 상속은 같은 타입을 가지는 하위 클래스를 여러 개 정의하는 것이다. * 상속은 클래스와 클래스의 결합도가 가장 높은 결합을 만든다. * 상속은 부모의 속성과 기능을 전부 물려받는다. (선별해서 상속받는게 불가능) * 클래스를 작성할 때 상속관계는 되도록 피해야 하는 관계다. * 사용방법이 같은 하위 구현클래스를 작성하게 한다. * 인터페이스를 이용한 구현은 클래스와 클래스의 결합도를 느슨하게 만든다. * 구현은 필요한 사양이 정의된 인터페이스만 구현할 수 있다...
-
학원 DAY 15. 추상화, 인터페이스, 추상클래스기록 2022. 10. 2. 20:50
> 의미 - 구현부가 없는 메소드(추상 메소드)를 정의하는 것. 목적 - 하위 클래스(구현 클래스)들이 반드시 구현할 기능을 추상메소드를 사용해서 추상화한다. 사용법이 동일한 하위 객체를 만들기 위함이다. (메소드 재정의를 강제 시키기 때문) (* 구현 클래스란? 구현 메소드로 구성된 클래스. 추상화된 메소드를 보유할 수 없다.) 추상화는 공통된 속성과 기능을 모아서 추상클래스나 인터페이스를 정의하는 것이다. 공통 속성은 변수나 상수로 표현하고, 기능은 추상메소드로 표현한다. > - 추상화의 수단이다. - 하위 구현클래스에 특정한 메소드가 반드시 존재하도록 강제할 때 사용한다. - 모든 하위 구현클래스의 사용법을 통일시키는 표준으로 사용된다. - 하위 구현클래스가 구현할 기능의 사양을 정의한다. (구현부..