Patrick's 데이터 세상
static 메소드 본문
반응형
SMALL
■ static 메소드의 정의와 호출
class NumberPrinter
{
public static void showInt(int ㅜ)
{
System.out.println(n);
}
public static void showDouble(double n)
{
System.out.println(n);
}
}
class ClassMethod
{
public static void main(String[] args)
{
NumberPrinter.showInt(20);
NumberPrinter np = new NumberPrinter();
np.showDouble(3.15);
}
}
˙ 실행결과
20
3.15
인스턴스를 사용하지 않아도, static 메소드를 호출할 수 있습니다.
반응형
LIST
'Programming > Java' 카테고리의 다른 글
JAVA내에서 정규표현식 사용(Pattern, matches) (0) | 2020.06.24 |
---|---|
Spring 개요 (0) | 2020.06.24 |
static 변수(클래스 변수) (0) | 2020.06.23 |
자바 이름 생성 규칙(Naming Rule) (0) | 2020.06.23 |
클래스, 인스턴스 (0) | 2020.06.23 |
Comments