-1

I want to print the two integer variables divided.

int a = 1, b = 2;
System.out.println(a + b);

Obviously println() function processes them as integers and calculates the sum. Instead I would like the output becomes like this "12". Any ideas?

TangledUpInBlue
  • 746
  • 4
  • 13
c jais
  • 11
  • 1

2 Answers2

0

Insert some blank Strings to induce this:

System.out.println(a +""+ b);
ctst
  • 1,610
  • 1
  • 13
  • 28
-2

Store the integers as strings:

String a = "1";
String b = "2";
String c = a + b;

System.out.println(c);
TangledUpInBlue
  • 746
  • 4
  • 13