loading

Numbers and Strings

Java Numbers and Strings

DISCLOSURE:

  • Java employs the + operator for concatenation and addition.
  • There is an addition of numbers. Concatenated strings are used.

A number is the outcome of adding two numbers:

Example

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

A string concatenation is produced when two strings are added:

Example

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

A string concatenation is what happens when you add a number and a string together:

Example

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

Numbers and Strings

Or copy link

Explore Topic