✨
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?

super, super()

reference type variable super, constructor super()

  • super

  1. reference type variable that indicates itself.

  2. exist within instance method(constructor).

  3. distinguish parent members between current members

class Parent {int x = 10;}

class Child extens Parent {
    int x = 20;
    
    void omethod() {
        System.out.prinln("x=" - x);
        System.out.prinln("this.x=" + this.x);
        System.out.prinln("super.x=" + super.x);
    }
}
  • super() : parent constructor

  1. call parent constructor

  2. initialize parent member by calling parent constructor

  3. add constructor in the first line otherwise compiler adds super(); automatically. 모든 생성자는 첫 줄에 다른 생성자를 호출해야한다. 그렇지 않으면 컴파일러가 자동으로 super()를 호출해버린다.

class Point {
    int x,y;
    
    Point() {
        this(0,0);//constructor in first line
    }
    
    Point(int x, int y) {
        
        this.x = x;
        this.y = y;
    }
}
class Point3D extends Point {
    int z;
    
    Point 3D(int x, int y, int z) {
        super(x,y);
        this.z = z;
    }
}
class Point{
    int x,y;
    
    Point(int x, int y) {
        //no constructor in first line
        //=>compiler will add super();
        this.x = x;
        this.y = y;
    }
}

class Point3D extends Point {
    int z;
    
    Point3D(int x, int y, int z) {
        super(x,y);//call parent constructor super()
        this.z = z;
        //this.x = x;
        //this.y = y;
        
    }
}

right code below :

  1. default constructor in Point class

  2. must call other constructor in first line

  3. super constructor in Point3D constructor

class Point {
    int x;
    int y;
    
    //1. default constructor
    Point() {}
    Point(int x, int y) {
        //2. must call other constructor in first line
        Point(){};
        this.x = x;
        this.y = y;
    }
    
}
class Point3D extends Point {

    int z;
    
    Point3D(int x, int y, int z) {
        
        Point(x,y);
        this.z = z;
    }
    
    
}

Previous(Method)OverridingNextpackage, class path

Last updated 4 years ago

Was this helpful?