Miêu tả
Phương thức Float.parseFloat() là phương thức static của lớp Float để chuyển đổi String thành Float.
Cú pháp
public static int parseFloat(String s)
Ví dụ
public class StringToFloatExample {
public static void main(String args[]) {
String s = "30.3";
float f = Float.parseFloat("30.3");
System.out.println("Gia tri cua f la: " + f);
}
}
Chạy chương trình Java trên sẽ cho kết quả:
Gia tri cua f la: 30.3

Post A Comment:
0 comments: