java 字符串转为基本数据类型

 1 public class ObjectDemo {
2 public static void main(String[] args) {
3 String str1="30";
4 String str2="30.3";
5 int x=Integer.parseInt(str1);
6 float f=Float.parseFloat(str2);
7 System.out.println("整数乘方"+x+"*"+x+"="+(x*x));
8 System.out.println("小数乘方"+f+"*"+f+"="+(f*f));
9
10 }
11
12 }

你懂的。、。

原文地址:https://www.cnblogs.com/dennisac/p/2384250.html