KodingKid

How to add strings and integers in Java - Basic Scripting #11

May 20th, 2021 (edited)
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. String string1 = "This is a string";
  2. String string2 = "and this is another string.";
  3. int integer1 = 100;
  4. int integer2 = 200;
  5. integer3 = integer1 + integer2;
  6. System.out.println(string1.concat(string2)); //you can also make a string 3 that is string 1 + string 2 like i did with the integers
  7. System.out.println(integer3);
  8. //fun fact, if the integers were strings, it'd output 100200
Add Comment
Please, Sign In to add comment