Name

str()

Description

Converts a value of a primitive data type (boolean, byte, char, int, or float) 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.

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'