Java入門・初心者質問スレ Part.6at TECH
Java入門・初心者質問スレ Part.6 - 暇つぶし2ch199:デフォルトの名無しさん
18/01/06 19:03:18.86 KWkl+TbG.net
>>186
class C {
 private static final Pattern p = Pattern.compile("^(\\-?(0|[1-9]\\d*)(\\.\\d+)?((e|E)(\\+|\\-)?\\d+)?)");
 public static int atoi(String s) {
  return toDouble(s).intValue();
 }
 public static double atof(String s) {
  return toDouble(s);
 }
 private static Double toDouble(String s) {
  Matcher m = p.matcher(s);
  if (!m.find()) {
   return new Double(0);
  }
  return new Double(m.group(1));
 }
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch