Overloading in Java In Java, If two or more methods in a class have the same method name but different parameters, the methods are defined as different methods even though it has the same method name. simple example code12345678910111213141516171819202122232425262728293031323334class Calculator { int a, b, c; public void setCal(int a, int b){ this.a = a; this.b = b; } //same method name with dif..
The specialties of Overriding 1. @Override annotation needed. 2. The parameter(s) and return type must be the same as an inherited from its superclass. 3. Super keyword needs to refer to a parent class.4. Final methods, private methods and Static methods cannot be overridden.5. a method overriding can only be written in a subclass, not in the same class. Example Code 1234567891011121314151617181..
SuperA super keyword refers to a parent class. Attaching () with super keyword means the constructor of the parent class. This ensures that no errors occur even if the default constructor for the parent class is lost. Example Code I1234567891011121314151617181920212223242526272829303132333435class Calculator { int a, b; public Calculator(){} //하위클래스가 호출될 때 자동으로 부모클래스의 생성자가 호출 //매개변수가 없는 기본생성자가 없..
Inheritance 상속 Inheritance in Java, it allows that a child class can acquire the features from a parent class, to avoid duplicate code and it is easy to maintain the program. 다른 클래스의 기능을 사용하고 싶을때 상속을 통해서 자식 클래스가 부모클래스의 기능을 그대로 사용할 수 있다. 그로인해 코드의 중복을 피할 수 있고 유지보수 또한 편리해지는 장점(하나가 변하면 다른 쪽도 자동으로 영향을 받기에)을 얻을 수 있다. extends keyword syntax class Bird extends Animal -> Class Bird inherits its super cla..
Constructor 1. A constructor has no return value, not even void. Constructor actually initializes the object of the class. If there is a return value, it would create an unexpected object. 첫번째, 생성자는 반환형이 선언되어 있지도, 반환형이 있지도 않다. 2. the Constructor name is the same as the class name. 두번째, 클래스의 이름과 동일하다. 3. the constructor can be overloaded여러개의 생성자가 존재할 수 있다. 4. if there is no constructor, a default..
Nested If-Else To avoid duplicated conditions and to make decisions in your program, the nested structure could be considered as a big frame of the program using If-Else statement. if else 로 문제를 접근할 때 중복조건을 피하고 우선순위를 정하기 위해 상위 하위에 속하는 구조(nested If-Else)를 먼저 파악한 후 틀을 잡고 문제를 해결 해 나갈 것! Q. Given an integer, , perform the following conditional actions:If is odd, print WeirdIf is even and in the incl..
- Total
- Today
- Yesterday
- ... in Javascript
- HackerRank Algorithm
- hackerrank javascript
- hackerrank solution
- hackerrank javascript solution
- string class in java
- java
- easy algorithm
- easy javascript algorithm
- Collection Framework
- HashMap
- substring()
- spring boot application
- Object type casting
- C++
- hackerrank
- code refactoring
- Javascript Algorithm
- javascript
- compareTo()
- equals()
- math.max
- 알고리즘
- algorithm
- math.abs
- repeat()
- 프로그래머스 알고리즘문제
- 프로그래머스 알고리즘
- 프로그래머스
- rest parameter
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |