static -> method / variables
class cal {
int a; int b;
static int c;
<평범한 instance 메소드 일때> => 다 접근 가능. 대신, instance 로(c1.) 꺼내써야함
void sum(){ a + b } (o) 가장 평범
void sum(){ c } (o)
c1.sum(a + b + c) (o)
<c1 안만들고 직접 하려고 static 메소드 쓸때> => Static 은 끼리끼리만 논다. 대신 직접 꺼낼수 있다.
static void sum(){ a + b } (x) int a, b (x)
static void sum(){ c } (o) static int c (o)
calcul.(static)sum ( c ) (o)
calcul.(static)sum ( a ) (x)
c1.(static)sum (x)
'Back to the Java' 카테고리의 다른 글
OOP 객체를 지향하는 프로그래밍을 지향하자 (0) | 2022.06.12 |
---|---|
BMI 비만 측정기, String.format() (0) | 2022.06.11 |
Math.random() 메소드 이용한 디아블로 전투 (0) | 2022.06.09 |
Back to the java - 로그인 Id pw 조건문 (0) | 2022.05.26 |
Back to the Java - Hellow! (0) | 2022.05.26 |