🌐
GeeksforGeeks
geeksforgeeks.org › java › java-hello-world-program
Java Hello World Program - GeeksforGeeks
Converts bytecode into native machine code at runtime for faster execution. ... 1. Create File: Save the file as HelloWorld.java. 2. Open Terminal: Navigate to the folder containing the file.
Published   January 19, 2026
🌐
Programiz
programiz.com › java-programming › hello-world
Java Hello World - Your First Java Program
Hello, World! // Your First Program In Java, any line starting with // is a comment. Comments are intended for users reading the code to understand the intent and functionality of the program. It is completely ignored by the Java compiler (an application that translates Java program to Java bytecode that computer can execute).
Discussions

Describe hello world program in java
If you've already been programming for a year, I guess I'll skip the really basic stuff. This defines a class called HelloWorld. Everything defined in Java has to live within a class. This source file, when compiled, will become a file called HelloWorld.class. There can be directives that exist outside a class (e.g. package and import). These are directives to the compiler. They influence how the compiler behaves while compiling that one file, but they do not "define" anything new, so they don't get placed inside the class. This class has a single method, main. The method has two modifiers: public - the method is available to callers that exist outside this class. static - the method can be called without first creating an instance of the class. The signature of a main method has to look like this. It has to be public and static, it has to return void, and it has to take a String array as a parameter. If you tweak that signature and then try to run the class, it won't work. The JVM won't be able to find a valid main method. System is a class in java.lang . But the package java.lang is automatically imported. That's why you don't need to write java.lang.System.out.println nor do you need an explicit import of java.lang. This is the only package that works this way. System has a static final field called out with type PrintStream . It's rare to expose fields in this way, but I suspect this was done for performance reasons. Like a static method, a static field can be accessed without creating an instance of the class. Because the field is final, its value cannot be swapped to reference a different PrintStream. And println is just a regular instance method on PrintStream. Dunno if that is what you wanted. More on reddit.com
🌐 r/learnprogramming
7
0
August 1, 2024
Simple HelloWorld java program - Java - Code with Mosh Forum
I created a sample java program in notepad and compile the code on dos prompt and I got the below error message Error: Could not find or load main class HelloWorldApp.class Caused by: java.lang.ClassNotFoundException: … More on forum.codewithmosh.com
🌐 forum.codewithmosh.com
0
September 24, 2022
Printing "Hello, World!" not working
Looks like a typo, you have "printIn", the capital letter being I, it is supposed to be a lower case "L". The command is "print line" hence "println". More on reddit.com
🌐 r/learnjava
10
9
May 28, 2023
Learning Java in 2024?

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or

  2. Temporarily refraining from using Reddit

  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

More on reddit.com
🌐 r/learnprogramming
76
55
January 28, 2024
🌐
DataCamp
datacamp.com › doc › java › first-java-program-hello-world
First Java Program: Hello World
Learn how to write, compile, and run your first Java program with our step-by-step guide on the "Hello, World!" example, perfect for beginners starting with Java.
🌐
Tutorialspoint
tutorialspoint.com › java › java_hello_world.htm
Java - Hello World Program
/* This is my first java program. * This will print 'Hello World' as the output */ These lines being in /* */ block are not considered by Java compiler and are comments. A comment helps to understand program in a better way and makes code readable and understandable.
🌐
Igmguru
igmguru.com › blog › first-java-program-hello-world
Java Hello World Program
2 days ago - Write your first Java hello world program with this step-by-step guide. In this article, you will get to learn how to create and run Java code.
🌐
Princeton CS
introcs.cs.princeton.edu › java › 11hello
1.1 Your First Java Program: Hello World
Write a program TenHelloWorlds.java that prints "Hello, World" ten times. Modify UseArgument.java to make a program UseThree.java that takes three names and prints out a proper sentence with the names in the reverse of the order given, so that for example, "java UseThree Alice Bob Carol" gives ...
🌐
Learn Java
learnjavaonline.org › en › Hello,_World!
Hello, World! - Learn Java - Free Interactive Java Tutorial
Let's go over the Hello world program, which simply prints "Hello, World!" to the screen. public class Main { public static void main(String[] args) { System.out.println("This will be printed"); } } The first line defines a class called Main.
🌐
freeCodeCamp
freecodecamp.org › news › hello-world-in-java-example-program
Hello World in Java – Example Program
June 7, 2022 - It won't be printed inside the code block above. I used // Hello World! as a way to show you the output of the code. That part of the code will not be executed by the compiler because it is a comment. We use two forward slashes (//) to start a single line comment in Java.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › tutorial › getStarted › application › index.html
Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started)
The "Hello World!" application consists of three primary components: source code comments, the HelloWorldApp class definition, and the main method.
🌐
Reddit
reddit.com › r/learnprogramming › describe hello world program in java
r/learnprogramming on Reddit: Describe hello world program in java
August 1, 2024 -

So I'm a newbie developer (1 yr exp), trying to get an understanding of core java. I've been coding for my company for a year now, but writing business logic doesn't seem to be helping much when it comes to improving my understanding of core java. Thought of doing an exercise of taking the simplest programs and going into detail about everything written in it.

Here's a simple hello world program in java:

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

Can I get as many details about what's happening in this file as possible? Like really go into the details here. Explain what each keyword does, why the print statement doesn't require an import, etc.

Top answer
1 of 2
4
If you've already been programming for a year, I guess I'll skip the really basic stuff. This defines a class called HelloWorld. Everything defined in Java has to live within a class. This source file, when compiled, will become a file called HelloWorld.class. There can be directives that exist outside a class (e.g. package and import). These are directives to the compiler. They influence how the compiler behaves while compiling that one file, but they do not "define" anything new, so they don't get placed inside the class. This class has a single method, main. The method has two modifiers: public - the method is available to callers that exist outside this class. static - the method can be called without first creating an instance of the class. The signature of a main method has to look like this. It has to be public and static, it has to return void, and it has to take a String array as a parameter. If you tweak that signature and then try to run the class, it won't work. The JVM won't be able to find a valid main method. System is a class in java.lang . But the package java.lang is automatically imported. That's why you don't need to write java.lang.System.out.println nor do you need an explicit import of java.lang. This is the only package that works this way. System has a static final field called out with type PrintStream . It's rare to expose fields in this way, but I suspect this was done for performance reasons. Like a static method, a static field can be accessed without creating an instance of the class. Because the field is final, its value cannot be swapped to reference a different PrintStream. And println is just a regular instance method on PrintStream. Dunno if that is what you wanted.
2 of 2
1
I don't do Java, but it looks close enough to C++ ... class HelloWorld is creating a new class, and the { and } at the beginning and end is the block. In that class, "public" is creating a public function called main() which returns a void, meaning it doesn't return anything when that function exits. Any public function can be called from outside of the class, whereas if it were private it would only be called from inside the class. String []args is probably defining an array of strings for the args that are being provided to the program from the command line, such as if you ran "program 1 2 3" then it would have three array elements, "1", "2", and "3". In C you'd also have an "int argc" before that which would tell you how many array elements there were. Again you have { and } which are telling you that its a block of code that all goes under main() Then you have what is essentially a printf( ) (in C) that outputs the string "Hello world", I assume to the screen. I don't know what a Java "import" is, .. but the reason that function doesn't require a type is probably because it is similar to C++ where the method is defined for multiple types and the Java interpreter knows which one to call based on whatever the type of the arg is. A java import that you mentioned might also be the C equivalent #include, which, if it is missing, I would assume that Java automatically imports the System class/object and doesn't make you declare it, but that's just a guess based on what you wrote. I don't know Java, so I don't know what "static" means in this context, because I don't think it means the same thing in Java that it means in C++
🌐
Baeldung
baeldung.com › home › java › java ‘hello world’ example
Java 'Hello World' Example | Baeldung
January 8, 2024 - In order to compile a Java program, ... ... Hello World! With this simple example, we created a Java class with the default main method printing out a string on the system console....
🌐
Happy Coding
happycoding.io › tutorials › java › hello-world
Hello World - Happy Coding
February 22, 2017 - They’re usually just a set of words listed after the command. You’ve actually already used them! When you type javac HelloWorld.java, you’re running the javac command and passing in HelloWorld.java as an argument.
🌐
Code with Mosh
forum.codewithmosh.com › java
Simple HelloWorld java program - Java - Code with Mosh Forum
September 24, 2022 - I created a sample java program in notepad and compile the code on dos prompt and I got the below error message Error: Could not find or load main class HelloWorldApp.class Caused by: java.lang.ClassNotFoundException: …
🌐
Oracle
docs.oracle.com › javase › tutorial › getStarted › cupojava › win32.html
"Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
First, start your editor. You can launch the Notepad editor from the Start menu by selecting Programs > Accessories > Notepad. In a new document, type in the following code: /** * The HelloWorldApp class implements an application that * simply prints "Hello World!" to standard output.
🌐
TheServerSide
theserverside.com › tip › 3-simple-Java-Hello-World-examples
3 simple Java Hello World examples | TheServerSide
It's a boring and banal introduction ... works. package com.example.helloworld.java; public class HelloWorld { public static void main(String args[]) { System.out.print( "Hello World!"...
🌐
Codecademy
codecademy.com › learn › java-introduction › modules › apcs-hello-world › cheatsheet
Intro to Java: Hello World Cheatsheet | Codecademy
The JVM (Java virtual machine) is used to run the byte code. # Compile the class file: javac hello.java · # Execute the compiled file: java hello · Copy to clipboard · Copy to clipboard · Whitespace, including spaces and newlines, between statements is ignored. System.out.println("Example of a statement"); System.out.println("Another statement"); // Output: // Example of a statement ·
🌐
Princeton CS
introcs.cs.princeton.edu › java › 11hello › HelloWorld.java.html
HelloWorld.java
/****************************************************************************** * Compilation: javac HelloWorld.java * Execution: java HelloWorld * * Prints "Hello, World". By tradition, this is everyone's first program. * * % java HelloWorld * Hello, World * * These 17 lines of text are comments.
🌐
GitHub
github.com › LuisJoseSanchez › hello-world-java
GitHub - LuisJoseSanchez/hello-world-java: Hello world with Java · GitHub
This is a simple "Hello world" done with Java programming language.
Starred by 18 users
Forked by 963 users
Languages   Java
🌐
W3Schools
w3schools.com › java › java_syntax.asp
Java Syntax
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... In the previous chapter, we created a Java file called Main.java, and we used the following code to print "Hello World" to the ...
🌐
GitHub
github.com › macagua › example.java.helloworld
GitHub - macagua/example.java.helloworld: "Hello World" Example for Java
"Hello World" Example for Java. Contribute to macagua/example.java.helloworld development by creating an account on GitHub.
Starred by 31 users
Forked by 281 users
Languages   Java 100.0% | Java 100.0%