자바 isNumeric()

Jmnote (토론 | 기여)님의 2017년 4월 16일 (일) 04:20 판 (새 문서: ==개요== ;자바 isNumeric() <source lang='java'> public static boolean isNumeric(String input) { try { Double.parseDouble(input); return true; } catch (NumberFormatE...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

자바 isNumeric()
public static boolean isNumeric(String input) {
  try {
    Double.parseDouble(input);
    return true;
  }
  catch (NumberFormatException e) {
    return false;
  }
}
...
//true
System.out.println( isNumeric("42") );
System.out.println( isNumeric("3.14") );
System.out.println( isNumeric("1e5") );

// false
System.out.println( isNumeric("A") );

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}