class toStringText
{
private int a = 10;
private float b = 10.0f;
private double d = 100.0d;
public static void main(String[] args)
{
int a = 10;
float b = 10.0f;
double d = 100.000000d;
char[] ch = {'h','e','l','l','o'};
System.out.println(String.valueOf(a));
System.out.println(String.valueOf(b));
System.out.println(String.valueOf(d));
System.out.println(String.valueOf(ch,2,3));
boolean bool = false;
System.out.println(String.valueOf(bool));
System.out.println(bool);
String str = " hello world! ";
System.out.println(str.trim()); //忽略字符串中的前部空格和后部空格
System.out.println(str.toUpperCase());//转化为大写
System.out.println(str.toLowerCase());//小写
char[] ch2 = str.toCharArray(); //字符串转化为字符数组
System.out.println(str.trim().startsWith("hello"));
}
}
java中String的基本用法
最新推荐文章于 2024-08-24 22:01:16 发布