java中String类型转换为float类型

import java.io.*;
public class Demo1{
  public static void main(String args[])
       {
 
            String df="12.2";
            float a=Float.parseFloat(df);
	    if(a>18)
	        System.out.println("你年龄大于18,要对自己的行为负责");
            else if(a>10 && a<18)
                System.out.println("你的年龄也不小了,把你送少管所");
	    else
	        System.out.println("小孩子,下次注意");					
       }
}

  

 程序猿必读

原文地址:https://www.cnblogs.com/longzhongren/p/4328661.html