String类的valueOf()代码:
package cn.tedu.string;
public class StringDemo7 {
public static void main(String[] args) {
//把布尔值转成字符串
String s=String.valueOf(true);
System.out.println(s);
//把小数转成字符串
String s1=String.valueOf(4.5);
System.out.println(s1);
//
int[] arr={3,4,5};
//底层依赖于String.valueOf()把整型数组的对象转成字符串对象—调用toString()
//就是拼接地址值
System.out.println(arr);
char[] cs={‘7’,‘8’,‘y’};
//没有转成字符串没有调用toString(),会把内容打印输出
System.out.println(cs);
//输出的是数组的地址值
System.out.println(cs.toString());
}
}
输出:
true
4.5
[[email protected]
78y
[[email protected]

代码图:
String类的valueOf()

相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2023-03-09
  • 2021-08-16
  • 2021-08-31
  • 2022-01-05
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2021-07-31
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2021-06-11
相关资源
相似解决方案