parseexam.java

来自「Java程序设计实用教程源代码 本书源代码按章分别放置在不同的文件夹中,所有程」· Java 代码 · 共 23 行

JAVA
23
字号
public class parseExam {
  public static void main(String args[]) {
    String str1 = new String("I love my motherland");
    String str2 = new String("150");
    String str3 = new String("1.9267 ");
    String str4 = new String("444.333 ");
    char[] myChar = new char[str1.length()];
    myChar = str1.toCharArray();
    int myInt = Integer.parseInt(str2);
    float myfloat  = Float.parseFloat(str3);
    double mydouble = Double.parseDouble(str4);
    for (int i = 0; i < myChar.length; i++)
      System.out.print(myChar[i]);
    System.out.println();
    System.out.println("myInt =" + myInt);
    System.out.println("myfloat =" + myfloat);
    System.out.println("mydouble =" + mydouble);
    System.out.println("Integer.valueOf(\"10902\") =" + Integer.valueOf("10902"));
    System.out.println("Float.valueOf(\"10.202\") =" + Float.valueOf("10.202"));
    System.out.println("Boolean.valueOf(\"true\") =" + Boolean.valueOf("true"));
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?