0
About Java Lesson _ Basic Concepts: Primitive Operator, second question
Was "println(result)" used because so far we haven't learned any other way to produce output? While playing around with the code I found out that just "print(result)". Are these always interchangable. If not which would be preferable in most of the cases and why? The lines of code I'm referring to: int x = 2; int y = 4; int result = x+y; System.out.println(result);
2 Respuestas
0
System.out.println(result); will print the output value for result and goes to next for next input..
But System.out.print(result) print result, continue in same line for next output...
So depends on requirements, you have to use..
0
Hello Nat
There exists also printf()
https://www.baeldung.com/java-printstream-printf