首页 > 文档 > str()字符串转换
2017
07-20

str()字符串转换

Name

str()字符串转换

   

Examples

boolean b = false;

byte y = -28;

char c = ‘R’;

float f = -32.6;

int i = 1024;

 

String sb = str(b);

String sy = str(y);

String sc = str(c);

String sf = str(f);

String si = str(i);

 

sb = sb + sy + sc + sf + si;

 

println(sb); // Prints ‘false-28R-32.61024’

Description

Converts any value of a primitive data type (booleanbytecharcolordoublefloatint, or long) to its String representation. For example, converting an integer with str(3) will return the String value of “3”, converting a float with str(-12.6) will return “-12.6”, and converting a boolean with str(true) will return “true”.

When an array of values is passed in, then a String array of the same length is returned.

将基元数据类型的任何值 (布尔、字节、char、颜色、双精度、浮点型、int long) 转换为其字符串表示形式。例如, 将一个整数转换为 str (3) 将返回 “3” 的字符串值, 将带有 str (-12.6) 的浮点转换为 “-12.6”, 并将布尔型转换为 str (true) 将返回 “true”

 

在传入值数组时, 返回相同长度的字符串数组。



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。