Java
[Java] μ μ λ©μλ
μ½λ©νλ λΆμ΄
2021. 2. 21. 02:50
λ°μν
βΆ μ μ λ©μλ
μ μ λ©μλλ static μμ½μ΄λ₯Ό μ¬μ©νμ¬ μ μΈνλ©° ν΄λμ€ μμ±κ³Ό 무κ΄νκ² μ¬μ©ν μ μλ€.
μ μ λ©μλλ₯Ό μ¬μ©ν λλ μΈν°νμ΄μ€ μ΄λ¦μΌλ‘ μ§μ μ°Έμ‘°νμ¬ μ¬μ©νλ€.
package interfaceex;
public interface Calc {
double PI = 3.14;
int ERROR = -999999999;
int add(int num1, int num2);
int substract(int num1, int num2);
int times(int num1, int num2);
int divide(int num1, int num2);
default void description() {
System.out.println("μ μ κ³μ°κΈ°λ₯Ό ꡬνν©λλ€");
}
static int total(int[] arr) { // μΈν°νμ΄μ€μ μ μ λ©μλ total() ꡬν
int total = 0;
for (int i : arr) {
total += i;
}
return total;
}
}
<μ€ν κ²°κ³Ό>
*private λ©μλ
-μλ° 9λΆν° κ°λ₯. μ°λ¦¬λ μλ° 8λ‘ μμ νλμ€ ... !!!
λ°μν