본문 바로가기
  • Adillete
【♣부트 캠프♣】/▷WIL

[15일TIL/ WIL] 인터페이스 이것이 자바다p.342-389

by 아딜렛 2024. 6. 8.

출처:https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html

 

ListIterator (Java Platform SE 8 )

An iterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. A ListIterator has no current element; its cursor position always lies betw

docs.oracle.com

 

Interface ListIterator<E>

  • boolean hasPrevious()
    Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous() would return an element rather than throwing an exception.)
    Returns:true if the list iterator has more elements when traversing the list in the reverse direction

『이것이 자바다 』 3판 1권, 신용권,임경균, 한빛미디어  p.342-389

class 이름 implements 인터페이스 이름

해당 클래스가 인터페이스를 통해 사용한다.

 

변수선언과 구현객체 대입

인터페이스를 통해 구현 객체를 사용하려면 인터페이스 변수에 구현 객체를 대입해야한다. 

구현 객체의 번지를 대입

 pu = new PubaoFamily();

pubaoFamily 객체를 생성하고 번지를 대입

pu.turnOn();  //인터페이스 변수에 구현 객체가 대입되었을때 변수를 통해
인터페이스의 추상 메소드를 호출가능하다.

 

추상메소드 : public 추상 메소드를 멤버로 가능

리턴타입 메소드명

turnOn() 추상 메소드