String.valueOf(x) of common String methods is a static method that converts various types of data into string types

String.valueOf(x) of common methods of String

1. Function

String.valueOf() is a static method that converts various types of data into string types. This method can convert a Boolean value, a character, a set of character arrays, an integer, a long integer, a floating-point number, a double-precision floating-point number, an Object object, and various other types of data to a string. For example, for an integer x, you can use String.valueOf(x) to convert it to a string.

Two, example

Convert a character type value to a String type value

		Character x = 'a';
		String value = String.valueOf(x);
		System.out.println(value);

Guess you like

Origin blog.csdn.net/weixin_43950588/article/details/131282093