LoginSignup
0
0

More than 3 years have passed since last update.

Javaで文字列を整数・小数に変換(データのキャスト)するメソッドについて

Posted at

データ型の変換(データのキャスト)

文字列等→整数・小数への変換

・整数へ変換するメソッド
Integer.parseInt(変数名);

・小数へ変換するメソッド
Double.parseDouble(変数名);

String text = "123"

System.out.println(text);  // 123 (文字列としてのそのまま出力)
System.out.println(Integer.parseInt(text)); // 123 (整数に変換)
System.out.println(Double.parseDouble(text)); // 123.0 (小数に変換)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0