Java: difference between print and return
In this practical tip, we briefly explain the difference between the Java commands print and return.
Java command explained: print
The "print" command in Java is there to output the content of an object in a print stream. This is usually a console. This means that the content of an object is completely output to the console.
- This will only pass the "1 + 1" object to the console, but nothing will happen.
- The print command is therefore important for the mere display of a text.
Java: return - what is it?
The Java "return" command, on the other hand, determines the value of a function and returns it as a return value.
- That is, in the example of a simple function such as "1 + 1", the value 2 is determined and returned as 2.
In another practical tip on the subject of Java, we explain how an if loop works.