Java 배우기145 Returning a Value from a Method 메소드로부터 값을 리턴하기 메소드로부터 값을 리턴하기 Returning a Value from a Method 메소드가 다음을 하는 경우, 어떤 것이든 먼저 발생되는 경우, 메소드는 그것을 invoke한 코드를 리턴합니다 A method returns to the code that invoked it when it메소드 안의 모든 명령문(statements)을 완료한 경우return 명령문에 도달한 경우, 또는 reaches a return statement, 또는 인 경우 리턴 스테이드 먼드ㅔ exception을 throw 한 경우(후에 다룸) throws an exception (covered later), 메소드 선언 안에 메소드의 return type을 선언합니다. 메소드의 몸체 내에서, 값을 리턴하기 위하여 return .. 2016. 1. 5. More on Classes 클래스 추가사항 클래스 추가사항 More on Classes 이 섹션은 객체 참조 사용에 의존하는 클래스의 보다 많은 측면과, 객체에 대한 앞선 섹션에서 배운 dot 연산자를 커버 합니다. This section covers more aspects of classes that depend on using object references and the dot operator that you learned about in the preceding sections on objects:메소드 로부터의 리턴 값 Returning values from methods.키워드 this The this keyword.Class vs. instance members.Access control. « DopZaClub » 2016. 1. 5. Using Objects 객체 사용하기 객체 사용하기 Using Objects 일단 객체를 만들고 나면, 아마도 뭔가에 사용하고 싶습니다. 객체의 필드 중 하나의 값을 사용하거나, 그 필드 중 하나를 변경하거나, 동작을 수행하도록 그 메소드 중 하나를 호출할 필요가 있을 것입니다. Once you've created an object, you probably want to use it for something. You may need to use the value of one of its fields, change one of its fields, or call one of its methods to perform an action. 객체의 필드 참조하기 Referencing an Object's Fields 객체 필드는 그 이름으로 접근합니.. 2016. 1. 5. Creating Objects 객체 생성하기 객체 생성하기 Creating Objects 잘 알다시피, 클래스는 객체에 대한 설계도입니다; 어떤 클래스로부터 어떤 객체 1개를 생성합니다. CreateObjectDemo 프로그램에서 취한 다음 명령문의 각각은, 객체를 생성하고 생성된 객체를 변수에 할당합니다: As you know, a class provides the blueprint for objects; you create an object from a class. Each of the following statements taken from the CreateObjectDemo program creates an object and assigns it to a variable:Point originOne = new Point(23, 94); R.. 2016. 1. 5. Objects 객체 객체 Objects 자바 프로그램은 많은 객체를 생성하는데, 객체들을 메소드들을 invoking함으로써 상호작용합니다. 이들 객체간 상호작용을 통하여, 프로그램은 GUI 구현, 애니메이션 가동 또는 네트웍 상에서의 정보 송수과 같은 다양한 과제들을 수행할 수 있습니다. 객체가 생성된 것에 대한 작업을 일단 완료하면, 그 리소스들을 다른 객체들이 재사용합니다.아래에 CreateObjectDemo라는 이름의 작은 프로그램이 있는데 이것은 1개의 Point 객체 및 2개의 Rectangle 객체 등 3개의 객체를 생성합니다. 이 프로그램을 컴파일하려면 모두 3개의 소스 파일이 필요합니다.A typical Java program creates many objects, which as you know, inter.. 2016. 1. 5. Passing Information to a Method or a Constructor 메소드 또는 생성자에게 정보 전달하기 메소드 또는 생성자에게 정보 전달하기 Passing Information to a Method or a Constructor 메소드 또는 생성자 선언은 해당 메소드 또는 생성자의 아규먼트의 갯수와 타입을 선언합니다. 예를 들어, 아래는 대출금액, 이자율, 대출기간(기간 수) 및 미래 대출금액에 근거한, 가계대출에 대한 매월 지급을 계산하는 메소드 입니다: The declaration for a method or a constructor declares the number and the type of the arguments for that method or constructor. For example, the following is a method that computes the monthly payme.. 2016. 1. 5. 이전 1 ··· 14 15 16 17 18 19 20 ··· 25 다음