Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Dec 19, 2024
1 parent 43a2cd0 commit e9caebe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions java/examples/other/MixedAdd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class MixedAdd {
public static void main(String[] args) {
String a = "19";
String b = "23";
int c = 23;
System.out.println("The sum: " + (a+b));
System.out.println("The sum: " + (a+c));
}
}
5 changes: 5 additions & 0 deletions java/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@

![](examples/other/MySubstring.java)

## Mixing types in add
{id: mixing-types-in-add}

* `+` is overloaded in Java so if one side is a string and the other is an integer, the integer will be automatically converted to a string and then `+` will be concatenation.

![](examples/other/MixedAdd.java)

0 comments on commit e9caebe

Please sign in to comment.