"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > System.out.println(\"Introduction to Java\")

System.out.println(\"Introduction to Java\")

Published on 2024-07-31
Browse:387

System.out.println(\

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Verbose Language?

When we start studying Java and look at the code above, we may be a little scared by the number of words needed to print a simple Hello, World!. This can sometimes give the impression that it is a difficult language, which can discourage beginners from exploring it in more depth right from the start, creating a kind of prejudice without a deeper understanding of the language.

What Are These Words: public, class, static, void, main...

When we execute the above code, the Java Virtual Machine (JVM) looks for the main block and executes it. Typically, applications have only a single method of this type, as the name suggests: the application's main method, the starting point.

public is an access modifier that indicates the type of the HelloWorld class, allowing it to be accessed by any other package. In addition to this, there are protected and private modifiers, which will be discussed at another time.

class is the reserved word used to indicate a class, which in this case is HelloWorld. It is important to remember that the class name must match the name of the Java file where it is defined (in this case, HelloWorld.java).

static indicates that the main method belongs to the HelloWorld class itself and not to specific instances of that class. This means that the method can be called without having to create an object of the HelloWorld class.

void is the return type of the main method, meaning that the method does not return any value.

String[] args is the parameter of the main method. args is an array of strings that allows you to pass command line arguments to the Java program when it runs.

Understanding these definitions, we can understand that Java is an imperative language. Unlike declarative languages, where we say what we want and the language decides how to carry out the process, in imperative languages ​​we need to provide instructions on how the process should be carried out. This provides us with some benefits, such as:

  1. Detailed control of the execution flow: In imperative languages, we have explicit control over how the program executes each step. This is useful for programmers to understand exactly what is happening and to optimize code performance.

  2. Easy to debug errors: As we specify each step of the process, it is easier to identify and correct errors when they occur. Error messages often clearly indicate where a problem occurred in the imperative code.

  3. Performance: In many cases, imperative languages ​​allow for more direct and efficient optimizations, as the programmer has control over how system resources are used.

  4. Adaptability to different contexts: Imperative programming is quite flexible and can be adapted to solve a wide range of problems, from the simplest to complex applications.

  5. State control: In imperative languages, program state is explicitly manipulated through variables and data structures. This makes it easier to manage mutable data and control the internal state of the program.

The fourth item takes us to a very important concept that we will cover at another time: Object Orientation.


In this article, we explore how the simple act of printing "Hello, World!" in Java introduces us to fundamental concepts of the language. Analysis of the keywords used in the code reveals the basic structure of a Java program and its meaning within the context of imperative programming.

By understanding the principles of imperative programming presented here—control flow, ease of debugging errors, performance optimization, adaptability, and state management—beginning programmers are equipped with essential tools for building and understanding robust, efficient Java programs .

In future articles, we will explore more advanced concepts, such as object orientation, that further expand Java's capabilities and open doors for developing complex, scalable applications.

Now that you understand the fundamentals, you are ready to explore the vast universe of Java programming deeper. Stay motivated and keep exploring new concepts to improve your skills as a developer.

I hope this article was useful for you to start your journey in the Java language. If you have any questions or suggestions, feel free to share them in the comments below.

Release Statement This article is reproduced at: https://dev.to/malheiros/systemoutprintlnintroducao-ao-java-35k5?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3