| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
XyzWs Java FAQ:
How does the result differ between the String and number operands of the '+' operator?
Printer-friendly version |
Mail this to a friend
|
Advertisement
|
How does the result differ between the String and number operands of the '+' operator?Let's take a look at the following example,
class Program {
public static void main(String[] args) {
System.out.println(1 + 2 + " fiddlers");
System.out.println("fiddlers " + 1 + 2);
}
}
The output is: 3 fiddlers fiddlers 12
The + operator is syntactically left-associative, the expression In the In the |