Java 배우기145 Providing Constructors for Your Classes 클래스에 생성자 제공하기 클래스에 생성자 제공하기 Providing Constructors for Your Classes 클래스에는, 객체를 생성하기 위하여 클래스 설계도로부터 invoke되는, 생성자(constructors)가 포함되어 있습니다. 생성자 선언은, 클래스 이름을 사용하고 리턴 타입이 없다는 점을 제외하고는 메소드 선언과 같습니다. 예를 들어, Bicycle은 1개의 생성자를 갖고 있습니다:A class contains constructors that are invoked to create objects from the class blueprint. Constructor declarations look like method declarations—except that they use the name of the c.. 2016. 1. 5. Defining Methods 메소드 정의하기 메소드 정의하기 Defining Methods 아래는 전형적 메소드 선언의 예 입니다: Here is an example of a typical method declaration:public double calculateAnswer(double wingSpan, int numberOfEngines, double length, double grossTons) { //do the calculation here } 메소드 선언의 필수항목은 메소드의 return 타입, 이름, 한 쌍의 괄호 (), 그리고 중괄호 {} 사이의 몸체 입니다.보다 일반적으로, 메소드 선언들은 다음의 6개 구성요소를 순서대로 갖고 있습니다:The only required elements of a method declaration are.. 2016. 1. 5. Declaring Member Variables 멤버변수 선언하기 멤버변수 선언하기 Declaring Member Variables 몇 가지 종류의 변수가 있습니다: There are several kinds of variables:클래스 안의 멤버변수 - 이들을 필드(fields)라고 합니다. Member variables in a class—these are called fields.메소드 또는 코드블록 안의 변수 - 이들을 로컬변수(local variables)라고 합니다. Variables in a method or block of code—these are called local variables.메소드 선언 안의 변수 - 이들을 패러미터(parameters) 라고 합니다. Variables in method declarations—these are calle.. 2016. 1. 5. Declaring Classes 클래스 선언하기 클래스 선언하기 Declaring Classes 다음과 같이 정의된 클래스가 있습니다:You've seen classes defined in the following way:class MyClass { // 필드(field), 생성자(constructor), 그리고 // 메소드 선언(method declarations)}이것이 클래스 선언 입니다.This is a class declaration. 클래스 몸체(중괄호 사이의 영역)에는, 클래스에서 생성되는 객체들이 살아있는 동안 제공되는 모든 코드 (새 객체들을 초기화하는 생성자들, 클래스와 그 객체들의 상태를 제공하는 필드, 클래스 및 객체들의 동작을 구현하는 메소드들에 대한 선언)가 포함됩니다.The class body (the ar.. 2016. 1. 5. Classes 클래스 클래스 Classes Object-oriented Programming Concepts 단원에서, 객체-지향 개념을 소개할 때 하위클래스가 경주 자전거, 산악 자전거 및 탠덤 자전거인, 자전거 클래스를 예제로 사용하였습니다. 아래에 자전거 클래스로 구현할 수 있는 샘플 코드가 있는데, 이 코드로 클래스 선언의 개요를 설명합니다.이 단원의 후속 섹션에서 단계 별로 클래스 선언을 백업하고 설명할 것입니다. 당분간, 세부 사항에 대한 걱정은 안하셔도 됩니다. The introduction to object-oriented concepts in the lesson titled Object-oriented Programming Concepts used a bicycle class as an example, wit.. 2016. 1. 5. Lesson: Classes and Objects 단원: 클래스와 객체 단원: 클래스와 객체 Lesson: Classes and Objects 자바 프로그래밍 언어의 기초를 알고 있다면, 클래스 만드는 방식을 배울 수 있습니다. 이 단원에는 멤버 변수, 메소드 및 생성자 선언하기가 포함된, 클래스 정의하기에 대한 정보가 있습니다.객체를 생성하기 위하여 클래스 사용 방법과 생성한 객체의 사용 방법을 배울 것입니다.이 단원에는 다른 클래스 안에서의 중첩(nesting) 클래스 및 열거(enumerations)도 포함되어 있습니다 With the knowledge you now have of the basics of the Java programming language, you can learn to write your own classes. In this lesson, you .. 2016. 1. 5. 이전 1 ··· 15 16 17 18 19 20 21 ··· 25 다음