🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Java Notes
Topic #31

Numbers and Strings


Adding Numbers and Strings

Warning: WARNING! Java uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated.

If you add two numbers, the result will be a number:

Example

int x = 10;
int y = 20;
int z = x + y;  // z will be 30 (an integer/number)

If you add two strings, the result will be a string concatenation:

Example

String x = "10";
String y = "20";
String z = x + y;  // z will be 1020 (a String)

If you add a number and a string, the result will be a string concatenation:

Example

String x = "10";
int y = 20;
String z = x + y;  // z will be 1020 (a String)

Want to go beyond the notes?

Join CodingNow 2.0's Java course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Numbers and Strings – FAQs

Quick answers about learning Numbers and Strings in Java.

This free note from CodingNow 2.0 explains Numbers and Strings in Java — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Java topic on CodingNow 2.0, including Numbers and Strings, is 100% free with no signup required.
With focused practice, most students grasp Numbers and Strings in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now