티스토리 뷰

반응형

public class Test {

 public static final String getJumin(String str) {

  String str1 = str;

   if( str1 == null){
    return "Number is null";
   }else if(str1.length() == 10){
    return str1.substring(0, 3) + "-" + str1.substring(3, 5) + "-" + str1.substring(5, 6) +"****";
   }else if(str1.length() == 13){
    return str1.substring(0, 6) + "-" + str1.substring(6, 7)+ "******";
   }else{
    return "wrong number";
   }
  }
  public static void main(String [] args){
   //String jumin_num = getJumin("8211061234567");
   String jumin_num = getJumin("1168169356");
   System.out.println("주민 번호: "+jumin_num);
  }
}


반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함