8) ¿QUÉ ES EL OUTPUT EN JAVA?

Java Output

You can simply use System.out.println()System.out.print() or System.out.printf() to send output to standard output (screen).
System is a class and out is a public static field which accepts output data. Don't worry if you don't understand it. Classespublic, and static will be discussed in later chapters.
Let's take an example to output a line.
  1. class AssignmentOperator {
  2. public static void main(String[] args) {
  3. System.out.println("Java programming is interesting.");
  4. }
  5. }
When you run the program, the output will be:
Java programming is interesting.
Here, println is a method that displays the string inside quotes.

What's the difference between println(), print() and printf()?

  • print() - prints string inside the quotes.
  • println() - prints string inside the quotes similar like print() method. Then the cursor moves to the beginning of the next line.
  • printf() - it provides string formatting (similar to printf in C/C++ programming).

Comentarios

Publicar un comentario