20 lines
485 B
Java
20 lines
485 B
Java
|
//: operators/StringOperators.java
|
||
|
import static net.mindview.util.Print.*;
|
||
|
|
||
|
public class StringOperators {
|
||
|
public static void main(String[] args) {
|
||
|
int x = 0, y = 1, z = 2;
|
||
|
String s = "x, y, z ";
|
||
|
print(s + x + y + z);
|
||
|
print(x + " " + s); // Converts x to a String
|
||
|
s += "(summed) = "; // Concatenation operator
|
||
|
print(s + (x + y + z));
|
||
|
print("" + x); // Shorthand for Integer.toString()
|
||
|
}
|
||
|
} /* Output:
|
||
|
x, y, z 012
|
||
|
0 x, y, z
|
||
|
x, y, z (summed) = 3
|
||
|
0
|
||
|
*///:~
|