Java programming language. Lessons for beginners from hyperskill


Introduction to Java


Java is a general-purpose modern programming language. The term "general-purpose" indicates the extensive range of capabilities Java offers. With Java, the possibilities are virtually limitless. The key feature of the language is platform independence: it means that the same Java program can be run on multiple platforms without any changes! This principle is also known as "write once, run anywhere" (or WORA).

Being one of the most popular languages in programming for many years, it has earned the top position in the TIOBE index (a general-purpose programming language popularity index). This robust programming language is used by a huge community of software developers around the world! If you have a problem, you can always ask other developers or find a suitable answer online.

This fundamental programming language is used in a wide variety of domains such as the financial services industry, telecommunications, embedded systems, in our Android smartphones to run mobile applications, and many other areas. Medical enterprise applications use it to store patient files, computer games, such as Minecraft, are created using Java; development tools like IntelliJ IDEA and Eclipse wouldn't exist without it.

§1. A short history overview

Java symbol. Basics

Java was initially developed by Sun Microsystems, and is currently owned by Oracle Corporation. The language project was initiated in 1991 by James Gosling and his colleagues. In the beginning, the language was called "Oak." Later, the project was renamed as a reference to Java coffee. For this reason, the language’s logo is a cup of coffee.

Sun Microsystems released Java 1.0 in 1996. After that, new versions were released every 1 to 3 years. Since Java 9, released in 2017, new versions have been released every 6 months. Starting from Java 11, every third major release is designated as an LTS version, which receives a minimum of 8 years of support. This allows organizations and developers to use stable, long-term supported versions of Java, ensuring reliability and security in their application development. You can read more about its history and find the most recent version on Wikipedia. Hyperskill currently supports versions up to Java 17.

§2. Some important features of Java

As we've mentioned before, the most important feature of Java is platform independence. This is achieved through the use of the Java Virtual Machine (JVM). When Java code is compiled, it is converted into platform-independent bytecode, which is executed by the JVM. At runtime, the JVM translates the bytecode into machine code. As a result, Java programs can run on any system that has a JVM.

Another important feature is a plain and clear syntax. Many elements of this simple language are easy to read and are widely used in other programming languages such as C/C++, C#, JavaScript, and Go.

If you have ever written programs in C/C++, you know that manual memory management can lead to bugs in the source code. Fortunately, the Java programming environment has a garbage collector that automatically cleans memory garbage from unused content during runtime.

It is also important to note that Java supports multiple programming paradigms; you will get to know more about them in future topics. As it's primarily an imperative language based on object-oriented programming, almost every part of a program is an object. Therefore, a program itself can be considered as a set of interacting objects. Also, it partially supports modern programming paradigms such as generic programming, concurrent programming, functional programming, and some others.

Java is one of the most popular programming languages, and many large systems and applications are based on it. Some well-known examples include application servers such as Apache Tomcat, JBoss, and WebLogic. Because of its reliability and performance, Java has been widely used in many large systems. It has been used to write popular services such as Netflix, Uber, and Spotify. Amazon uses Java to develop their web services.

Java has a huge active developer community. There are many forums, blogs, chat rooms, and websites where you can find help, tips, and programming guides.

There are also many libraries and frameworks based on Java, for example, Spring and Hibernate, which greatly simplify application development and extend the functionality of the language. With such a large community, Java developers have access to a wealth of knowledge, experience and support that contributes to the successful development and support of Java projects.

If you are a beginner in programming, it may be difficult to comprehend all the methods, complex features and key concepts of Java right now. This is not a bad thing. Throughout this set of topics, you will learn about all of these key concepts. Also, Java Docs have comprehensive online documentation that comprises guides, tutorials, specifications, API documentation, technical information, and more. We will refer you to it from time to time during your studies.

All in all, Java is a modern and popular programming language that can be successfully used in almost all domains.

You can also view Lesson on

Practical tasks and answers

Tasks and answer options are given. The correct option is highlighted in blue color.

№1. Crafting a 'Hello, World!' program

Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!

Question: You are given scrambled lines of a simple introductory Java program which, when arranged correctly, will print the statement 'Hello, World!'. The program involves creating a public class named 'HelloWorld', writing a main method, declaring a String variable, and using 'System.out.println' to print the given string. Your task is to correctly reorder these lines to form a functional Java "Hello, World!" program.

Drag the lines or use the arrows on the right to change the order. Use the buttons on the left to change the indentation:

Hint: Don't forget to use the correct indentation!

The correct answer will be:

public class HelloWorld {
    public static void main(String[] args)
        String helloWorld = "Hello, World!";

Explanation. The first line declares a public class named HelloWorld.

The second line defines the main method of the class. The main method is where the program starts executing.

The third line declares a String variable named helloWorld and initializes it with the value "Hello, World!".

The fourth line prints the value of the helloWorld variable to the console.

№2. Memory cleaning

Question: Which of the following is true about memory cleaning mechanisms in Java? If you forget this, just look again at the theory and find the answer.

Select one option from the list:

  • Java has a mechanism that cleans memory automatically. ✔
  • Java does not have memory cleaning mechanisms at all.
  • Java involves the use of a manual memory cleaning.

Explanation. The correct answer is Java has a mechanism that cleans memory automatically.

Java uses a garbage collector to automatically manage memory. The garbage collector tracks all the objects that are created in a Java program and frees up the memory that is no longer being used. This means that Java programmers do not need to worry about manually cleaning up memory.

Java tries to minimize manual memory management to avoid some possible bugs.

The other two options are incorrect. Java does have memory cleaning mechanisms, and it does not involve manual memory cleaning.

№3. Hello, User!

Question: Copy the given code to the text area below and put your name instead of <NAME> (e.g. John). Use only English letters to write the name. Your solution should not contain <>.


class Main {
    public static void main(String[] args) {
    System.out.println("Hello, <NAME>!");

Then click Run button (or Check button if you use IDE). Now, you do not need to understand how this code works, just enjoy it! :)

Write a program in Java 17.

Answer: Just insert any name in English letters instead of <NAME>.

Why learn Java?

Java is a general-purpose, object-oriented programming language that is used to create a wide variety of applications, including web applications, mobile applications, and desktop applications. It is a popular language for beginners because it is relatively easy to learn and use. Java is also a powerful language that can be used to create complex applications.

Here are some of the things you can do with Java:

  • Create web applications: Java is a popular language for creating web applications. It is used by many popular websites, such as Google and Amazon.
  • Create mobile applications: Java is also a popular language for creating mobile applications. It is used by many popular mobile apps, such as Instagram and Uber.
  • Create desktop applications: Java can also be used to create desktop applications. It is used by many popular desktop apps, such as Eclipse and Spotify.
  • Create games: Java can also be used to create games. It is used by many popular games, such as Minecraft and Angry Birds.

If you are interested in learning Java, there are many resources available to you. You can find online tutorials, books, and courses. You can also find Java programmers who can help you learn the language.

Here are some of the benefits of learning Java:

  • Java is a popular language: Java is a popular language, so there are many jobs available for Java programmers.
  • Java is a versatile language: Java can be used to create a wide variety of applications.
  • Java is a portable language: Java code can be run on any platform that has a Java Virtual Machine (JVM).
  • Java is a secure language: Java has built-in security features that help to protect your applications from attack.

If you are a high school or first-year student who is interested in becoming a programmer, I encourage you to learn Java. It is a great language to learn for beginners, and it is a language that will be in demand for many years to come.

Here are some tips for learning Java:

  • Start with the basics: Learn the fundamental concepts of Java, such as variables, data types, operators, and control flow statements.
  • Practice, practice, practice: The best way to learn Java is to practice writing code. There are many online coding challenges and exercises that you can use to practice your skills.
  • Join a community: There are many online communities for Java programmers. These communities can be a great resource for learning from other programmers and getting help with your problems.
  • Don't give up: Learning a new programming language can be challenging, but it is also very rewarding. Don't give up if you get stuck. Just keep practicing and you will eventually succeed.

Welcome to Learning Java!