String Examples

432 views.

Chaining Of Methods:

Output:

0

Rule:

If both the operands are of numeric type then + operator will perform addition and if at least one operand is of string type then + operator will perform concatenation.

Program

Output

Hello123
1Hello23
3Hello3
6Hello
3Hello3
1Hello5

Rule:

When the string objects are compared by using equals(), then it will compare the contents of the string and if we compare the string objects by using == operator, then it will compare the reference (hashcodes) of the objects.

Program

Output:

true
true
true
false
false
false

 

Leave a Reply