stringconversedemo.java

来自「JAVA编程思想源代码 值得一下 很难找的」· Java 代码 · 共 30 行

JAVA
30
字号
package chapter8;

public class StringConverseDemo {

	public static void main(String[] args) {

		// other to string
		int x1 = 11;
		String s1 = String.valueOf(x1);
		System.out.println("the string of x1 is  " + s1);
		s1 = Integer.toString(x1);
		System.out.println("the string of x1 is  " + s1);
		Integer x2 = new Integer(12);
		String s2 = x2.toString();
		System.out.println("the string of s2 is  " + s2);

		// string to other
		Float f1;
		String s3 = "1.1";
		f1 = Float.parseFloat(s3);
		System.out.println("the number of s3 is  " + f1);
		Integer x3;
		String s4 = "5";
		x3 = Integer.valueOf(s4);
		System.out.println("the number of s4 is  " + x3);

	}

}

⌨️ 快捷键说明

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