본문 바로가기

Java 배우기145

"Hellow world!" 프로그램 Lesson: A Closer Look at the "Hello World!" Application Now that you've seen the "Hello World!" application (and perhaps even compiled and run it), you might be wondering how it works. Here again is its code: 자바은 전통적인 "Hello, world!" 프로그램을 아래와 같이 작성합니다: The traditional "Hello, world!" program can be written in Java as:class HelloWorldApp { public static void main(String[] args) { System.out.prin.. 2016. 1. 4.
Modifier 접근제한자 여기서 modifiers란 public, protected, default, private등을 말하는데, 각각에 대한 자세한 설명은 부록의 Package & Access Modifier 특강에서 하고 있으니 바로 지금 참고하기 바랍니다.Package & Access Modifier 특강을 보았다면, 다음의 정리된 설명을 쉽게 이해할 수 있습니다. public: 어느 class에서나 참조 가능.protected: 같은 package 내의 class에서만 참조 가능, 자식 class가 다른 package에 있을 경우, 그 자식class도 참조가능.default: 같은 package 내의 class에서만 참조 가능.private: 같은 class 내에서만 참조 가능. 2016. 1. 4.
Member field(variable) method 멤버 필드(변수) 메소드 멤버(member)란 멤버 변수(member variable)와 멤버 메소드(member method)를 말합니다. 멤버 변수를 만드는 방법 ; 예) public int var; 멤버 메소드를 선언하는 방법 (아규먼트 목록) throws {....} 예) public int func (int x, int y) {...} 메소드를 선언할 때 주의할 사항은 다음과 같습니다. 1. return type이 없을 경우에는 void 라고 씁니다. 2. 아규먼트가 없을 때는 void 라고 쓰지 않고 그냥 비워둡니다(C 언어와 다름). // PassDopza.Java public class PassDopza { int pdValue(멤버 변수 이름) = 0; public void changeInt(멤버 메소드 이름) .. 2016. 1. 4.
Method 메소드 아래는 전형적인 메소드 선언 (method declaration)의 예제입니다. public double calculateAnswer (double wingSpan , int numberOfEngines , double length , double grossTons ) { //여기서 계산합니다 } 메소드 선언에서 요구되는 항목들은 메소드의 return type, 이름, 한 쌍의 괄호 (), 그리고 중괄호 {} 사이의 body 들 뿐입니다. The only required elements of a method declaration are the method's return type, name, a pair of parentheses, (), and a body between braces, {}. 보다 일반.. 2016. 1. 4.
자바 쉬운 예제 How do you reference a data member/function? 데이터 멤버/함수를 참조하는 방법은? This is accomplished by stating the name of the object reference, followed by a period (dot), followed by the name of the member inside the object. 객체 참조의 이름을 적고, 그 뒤에 .(점)을 찍은 다음, 그 뒤에 객체의 안에 있는 멤버의 이름을 적어서 데이터터 멤버와 함수를 참조 합니다. ( objectReference.member ). You call a method for an object by naming the object followed by a period (.. 2016. 1. 4.
참조 (reference)와 참조변수 (reference variable) 연산자 new는 클래스의 새로운 인스턴스에 대한 참조(reference)를 리턴합니다.The new operator returns a reference to a new instance of a class.  * 여기서 참조(reference)는 참조변수(reference variable)와 다르다는 점을 주목해야 하는데,  참조(reference)는 참조변수(reference variable)가 아닌 참조값(reference value, 해시코드)입니다.    클래스의 참조변수(reference variable)에 참조(reference)를 할당할 수 있습니다.This reference can be assigned to a reference variable of the class.   * 즉, 참조값(r.. 2016. 1. 3.