how to add two numbers in java

how to add two numbers in java

To add two numbers in Java, you can use the + operator. Here's an example of how to do this:

int x = 5;
int y = 7;
int sum = x + y;
Sour‮www:ec‬.lautturi.com

This will add the two numbers x and y and store the result in the sum variable.

You can also use the + operator to concatenate strings. For example:

String s1 = "Hello";
String s2 = "World";
String s3 = s1 + s2;

This will concatenate the two strings and store the result in the s3 variable.

Created Time:2017-11-01 12:05:11  Author:lautturi