Try
System.out.println(num1+" x "+num2+" = "+result+"
");
UPDATE: Some of you are saying this concatenation method is slower than other methods. You are right, it is slower, but does it really matter for this example?
This method is usually used to debug, not as part of the final code, and usually only once or twice on the whole code.
Faster method:
System.out.printf("%d x %d = %d
",num1,num2,result);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…