✨
Java
  • 자바의 역사
  • Ch1
    • Before Start Java
      • History of Java
      • Feature of Java
      • API Documentation
      • Hello World!
      • eclipse shortcut
      • Eclipse IDE
      • GitHub to eclipse
  • Ch2
    • Variable
      • Variable
    • Variable Type
    • Character and String
    • Primitive type and range
    • printf and formatter
    • Scanner
    • Overflow of Int
    • Transition between different variable types
    • Object Array
  • CH3
    • Operator
  • CH4
    • 조건문과 반복문
    • if statement
    • switch
    • Math.random()
    • for statement
    • while statement
    • break, continue, named iterated statement
  • CH5
    • Array
    • 배열 활용
    • String Array
  • OOP
    • Intro
  • Class and Object
  • Make multiple Classes in one file
  • How to use Object
  • Object Array
  • Variable type according to declared location
  • Class Variable and Instance Variable
  • Method
  • Call Stack
  • Parameter
  • Static method(Class method) and Instance method
  • (Method)Overloading
  • Constructor
  • Constructor this()
  • Reference type variable "this"
  • Initialize variable
  • Inheritance
  • Composite
  • Single Inheritance, Object Class
  • (Method)Overriding
  • super, super()
  • package, class path
  • import, static import
  • modifier
  • access modifier
  • Encapsulation
  • Polymorphism
  • reference type transition
  • instanceof operator
  • Parameter polymorphism
  • Multiple object using one array
  • Abstract Class, Abstract Method
  • Creating Abstract Class
  • Interface
  • Interface Polymorphism
  • Interface Pros
  • Default method and static method
  • Inner Class
  • Anonymous Class
  • java.lang package and useful class
    • Object class
    • hashCode(), toString()
    • String class
    • StringBuffer class
    • StringBuilder class
    • Math class
    • Wrapper class
    • Number class
    • String to Number, String to Wrapper class
    • Auto-boxing and (auto)Unboxing
  • Collection Framework
    • Collections framework
    • List, Set, Map Interface
    • List의 removeAll() 과 clear() 비교
    • List Interface - ArrayList
    • How to view Java API source
    • List Interface - LinkedList
    • Stack and Queue
    • Iterator, ListIterator, Enumeration
    • Array
    • Comparator와 Comparable
    • Stack
    • String
    • String + char = String
    • String.toCharArray()
    • BufferedReader / BufferWriter
    • Scanner로 String 입력 - next( )와 nextLine( )
    • 공백없이 2차원배열 데이터 String으로 한번에 한줄씩 입력받기(문자/숫자)
    • 공백을 사이에 두고 빠른 2차원 배열 입출력
    • arr[index++]과 arr[index] index++의 차이
    • int와 long의 차이
    • Untitled
    • 타입 간의 변환
    • Array 와 ArrayList
    • valueOf()
    • Char
    • 변수, 객체 초기화(초기값 설정)
  • error troubleshooting
    • No enclosing instance of type
    • ASCII Code Table
    • java.lang.NumberFormatException
    • No enclosing instance..
  • reference
    • String을 생성하는 2가지 방법과 차이점
    • StackOverflowError(스택, 힙 메모리)
    • swtich-case 반복문
Powered by GitBook
On this page

Was this helpful?

Interface

Interface Declaration, Inheritance, Implementation

-In Java programming aspect, interface is a group of abstract methods. It also includes static method, inheritance, default methods.

-Interface connects objects. Java를 활용한 Spring을 배울 때 인터페이스에 대해 혼동하지 말자.

-There is nothing implemented in interface.

-All of members are public.

Encapsulation : t.hour(x) . t.getHour(o)

  • Difference between interface and abstract class

  1. Abstract class : The class that has abstract methods. It has not only abstract methods, but also constructor and iv(instance variable/instance method).

  2. Interface : The one that only have abstract methods. It cannot have any other things.

  • Interface Declaration

interface (name) {
    public static final (type) (name) = (value);
    public abstract (method_name) (parameter_list);
}
interface PlayingCard {
    // some parts can be skipped. 
    public static final int SPADE = 4;
    final int DIAMOND = 3;//public static final int DIAMOND = 3;
    static int HEART = 2;//public static final int HEART = 2;
    int CLOVER = 1;//public static final int CLOVER = 1;
    
    public abstract String getCardNumber();
    String getCardKind();//public abstract String getCardKind();
}

interface CANNOT have variable such as iv, cv...

interface ALWAYS have public static final.(no exception, always constant.)

interface ALWAYS have public abstract methods.

  • Interface Inheritance

-Interface parent can be only interface.(Object is not the root.)

-Multiple inheritance is possible : Java is single inheritance because conflict between same name from different classes and different implementation. But when it comes to abstract method, even though it is same name, it has no implemented part so it does not matter.

-It is same as implementing abstract class by inheritance using "extends". The only difference is using keyword "implements"

-Implement(Complete) abstract method.

interface Fightable {
    
    (public abstract) void move(int x, int y);
    (public abstract) void attack(Unit u);
}
//Fight class implements Fightable interface
//"abstract" does not exist in front of Fighter class.
class Fighter implements Fightable {
    //implement abstract method
    public void move(int x, int y) {..}
    public void attack(Unit u) {..}
}
//implement only some parts then add "abstract"
abstract class Fighter implements Fightable {
    public void move(int x, int y)
}
PreviousCreating Abstract ClassNextInterface Polymorphism

Last updated 4 years ago

Was this helpful?