GithubHelp home page GithubHelp logo

bitcamp-java-project-01's Introduction

26-c. 중첩 클래스 : 로컬 클래스(local class)

이번 훈련에서는 로컬 클래스 문법을 사용하여 Iterator 구현체를 만들어 볼 것이다.

로컬 클래스(local class) 는,

  • 메서드의 로컬 변수와 사용법이 유사하다.
  • 특정 메서드에서만 사용할 클래스라면 그 메서드 내부에 정의하는 것이 코드를 읽기 쉽고 유지보수 하기 쉽게 만든다.
  • 로컬 클래스도 바깥 클래스의 멤버에 직접 접근할 수 있다.
  • 인스턴스 메서드는 this 라는 내장 변수에 인스턴스 주소를 담고 있다.
  • 인스턴스 메서드에 정의된 로컬 클래스에서도 이 this 변수를 사용할 수 있다.

훈련 목표

  • 로컬 클래스 를 만들고 사용하는 방법을 배운다.
  • 로컬 클래스 의 용도와 이점을 이해한다.

훈련 내용

  • ListIterator 구현체를 로컬 클래스로 정의한다.
  • StackIterator 구현체를 로컬 클래스로 정의한다.
  • QueueIterator 구현체를 로컬 클래스로 정의한다.

실습

1단계 - ListIterator 구현체를 iterator() 메서드 안에 정의한다.

  • AbstractList 클래스
    • ListIterator 구현체를 iterator()의 로컬 클래스 로 정의한다.

작업 파일

  • com.eomcs.util.AbsractList 클래스 변경

2단계 - StackIterator 구현체를 iterator() 메서드 안에 정의한다.

  • Stack 클래스
    • StackIterator 구현체를 로컬 클래스 로 정의한다.

작업 파일

  • com.eomcs.util.Stack 클래스 변경

3단계 - QueueIterator 구현체를 iterator() 메서드 안에 정의한다.

  • Queue 클래스
    • QueueIterator 구현체를 로컬 클래스 로 정의한다.

작업 파일

  • com.eomcs.util.Queue 클래스 변경

실습 결과

  • src/main/java/com/eomcs/util/AbstractList.java 변경
  • src/main/java/com/eomcs/util/Stack.java 변경
  • src/main/java/com/eomcs/util/Queue.java 변경

bitcamp-java-project-01's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.