TIL_Java_static,void

kyoungyeon·2022년 10월 24일
0

TIL

목록 보기
55/110

개념:
static: 정적인것.
클래스와 연결, static이 붙은 메소드는 다 호출가능

void:
차이: 리턴'값'이 없음
리턴이 없는거임.
타입이 void라는 것은 반환할 것이 없다는 의미입니다. 즉, 메인 메서드를 호출하는 JVM(Java Virtual Machine)에서 반환값을 요구하지 않으니 void타입을 사용합니다(멀티 스레드를 염두했기 때문).
출처
java.lang.Void : Class Void
실체화 할 수 없는 클래스
javadocs

주의

  • javascript undefined > null 처럼 포함관계 X
  • java 는 null(값이없음) 로 도출됨
public class StringEmptyCheck {    public static void main(String[] args) {         String str1 = null;        String str2 = "";        String str3 = " ";         System.out.println("str1 : " + isStringEmpty(str1)); // true        System.out.println("str2 : " + isStringEmpty(str2)); // true        System.out.println("str3 : " + isStringEmpty(str3)); // true     }     static boolean isStringEmpty(String str) {        return str == null || str.trim().isEmpty();    }}

String(문자열) 빈 값 체크하기

profile
🏠TECH & GOSSIP

0개의 댓글