Introduction

Hello, future programmers! Are you ready to kickstart your journey with Java? Today, we'll dive into the basics of Java — syntax and comments — and you'll write your first simple Java program.

Java, a widely-used, platform-independent language, is our spaceship for this exciting journey. Various applications, from mobile to enterprise-level, are built using Java. Here's an interesting fact: the game Minecraft was developed in Java!

Like the rules of English grammar, Java follows its own set of rules, known as syntax. Let's explore together!

Java Syntax Basics

In Java, we use statements to perform actions, and each statement ends with a semicolon (;). Java employs curly braces ({ }) to define a block of code.

Look at this simple Java syntax example:

In this example, we've declared a class MyFirstProgram, included the main method, which is where the program starts executing, and presented a statement that prints "Hello, Java World!". You might not understand every single line of this code right now, but that's fine! We will cover it step-by-step in this and the next lessons.

Say Hello to Comments

In code, we leave notes for ourselves — these are known as comments. These comments (notes) do not affect code execution in any way and are used to clarify things or leave some helpful notes for future developers (or yourself) working on this code. In Java, we use for single-line comments and for multi-line comments.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal