본문 바로가기

Java 배우기145

Bounded Type Parameters Bounded Type ParametersThere may be times when you want to restrict the types that can be used as type arguments in a parameterized type. For example, a method that operates on numbers might only want to accept instances of Number or its subclasses. This is whatbounded type parameters are for.To declare a bounded type parameter, list the type parameter's name, followed by the extends keyword, fo.. 2016. 1. 24.
Generic Methods Generic Methods제네릭 메소드는 자신의 타입 패러미터를 소개하는 메소드입니다. 제네릭 메소드는 제네릭 타입 선언과 유사하지만, 타입 파라미터의 범위가 선언된 메소드 안으로 한정됩니다. 스테틱 및 비-스테틱 제네릭 메소드가 허용되며 제네릭 클래스 생성자도 허용됩니다. 제네릭 메소드의 신택스에는 타입 패러미터, 내부 앵글 괄호가 포함되며, 메소드의 리턴 타입 앞에 나타납니다. 스테틱 제네릭 메소드의 경우, 타입 패러미터 섹션은 메서드의 리턴 타입 앞에 나타나야 합니다.Util 클래스는 제네릭 메소드 compare를 포함하는데 이것은 2개의 Pair 객체를 비교합니다: Generic methods are methods that introduce their own type parameters. Thi.. 2016. 1. 24.
Raw Types Raw Typesraw type은 타입 아규먼트가 없는 제네릭 class나 interface의 이름입니다. 예를 들어, 아래와 같이 generic Box class가 주어진 경우: A raw type is the name of a generic class or interface without any type arguments. For example, given the generic Box class: public class Box { public void set(T t) { /* ... */ } // ... } parameterized type의 Box를 만들기 위하여, formal type parameter T에 대하여 실제 타입 아규먼트를 공급합니다: To create a parameterized t.. 2016. 1. 24.
제네릭 타입 Generic Types 제네릭 타입 Generic Typesgeneric type은 타입에 걸쳐 패러미터화된 generic class 또는 interface입니다. 다음의 Box 클래스는 개념을 데모하기 위하여 수정됩니다. A generic type is a generic class or interface that is parameterized over types. The following Box class will be modified to demonstrate the concept. 간단한 Box클래스 A Simple Box Class어떤 타입의 객체에서도 연산되는 non-generic Box class를 검토하는 것으로 시작합니다. 이 클래스는 메소드 상자에 객체를 추가하는 set와 상자를 검색하는 get의 메소드 2개를.. 2016. 1. 24.
Why Use Generics? 제네릭스를 사용하는 이유 제네릭스를 사용하는 이유 Why Use Generics? 간단히 말해서, 클래스, 인터페이스와 메소드를 정의할 때, 제네릭스로 타입 (클래스와 인터페이스)을 패러미터로 만들 수 있습니다. 메소드 선언에 사용되는 보다 익숙한 포멀 패러미터와 같이, 타입 패러미터는 다른 입력과 동일한 코드를 재사용 할 수 있는 방법을 제공합니다. 차이점은 포멀 패러미터에 대한 입력은 값(values)이고, 타입 패러미터에 대한 입력은 타입이라는 점입니다.제네릭스를 사용하는 코드는 비-제네릭 코드에 비해 많은 장점을 갖고 있습니다 :In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfa.. 2016. 1. 24.
Lesson: Generics (Updated) 단원: 제네릭스 (업데이트된) 단원: 제네릭스 (업데이트된) Lesson: Generics (Updated) 어떤 사소한 소프트웨어 프로젝트에서도, 버그는 단순히 피할 수 없는 현실입니다. 신중한 계획, 프로그래밍, 테스팅이 버그를 줄일 수 있지만, 어떻게든 어디에서든, 버그들은 항상 코드에 스며들 방법을 찾으려 합니다. 새로운 기능이 도입되고 코드 베이스의 크기와 복잡성이 증가함에 따라 이런 현상은 보다 분명해집니다. In any nontrivial software project, bugs are simply a fact of life. Careful planning, programming, and testing can help reduce their pervasiveness, but somehow, somewhere, they'l.. 2016. 1. 5.