FAQ: Hello World: Java - Introduction to Java

This community-built FAQ covers the “Introduction to Java” exercise from the lesson “Hello World: Java”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Java

FAQs on the exercise Introduction to Java

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hey! how do I check the java version that is being used in this tutorial ?

Hello, @object3757487760.

In a lesson where you can type in the console, you can execute java --version.

3 Likes

use big brain
:grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning:

In the webpage I’m unable to access the second and third panes. The text editor is shadowed in dark grey.

Hello @methodace11976 and welcome to the Codecademy Forums!

Do you see the message that you are “Connected to Codecademy”?

If not, check out this topic.

No I don’t see connected to Codecademy. When I tried to start the 7 day trial there was no credit card field I could enter my card number into.

Thank you
Maxine

Did you check out the Troubleshooting Guide I linked above? It contains many potential solutions when you are unable to connect to Codecademy.

As for the PRO free trial, try this link.

Hey for java, do I have to type the whole script (public class HelloWorld {
public static void main(String args) {
System.out.println("") for java to print out 1 message?

You will learn more about classes and methods in later lessons. For now, yes, you do need to create a class and a main method to print out a message.

When you run your program, the compiler looks for a main method to run. This method is automatically executed whenever you run your program, so any code inside, including System.out.println(""); will be run.

Welcome to the forums!

Hi Dr_victoria! How long it will take me to learn Java? or C, C++?

First things first, what is your definition of “learn”? To know the basics and syntax of a language, to be able to apply your knowledge to different projects? To just get through the Codecademy course? Think about why you want to learn to program, how much spare time you have, and how invested you are into this.

Secondly, everyone learns at a different pace. No one has the same learning experience as another. Additionally, I only have experience with Java, not C or C++, so I can’t comment on those two languages. What I can say is that after 2 short, “crash course”-like courses, each lasting about a month, I’m relatively confident in Java and can breeze through the Codecademy course. This does not mean, however, that I can go and write any functioning program that I want. It simply means that I can write almost all simple and intermediate programs and some more advanced ones.


This video might be of help:


Any others, please feel free to comment with your own experiences, since mine are limited to, well, my own.

Like any language you speak or write it is a lifetime journey.

whats is void main() i know main() function purpose but i don’t know void purpose can you explain this void uses?

void is a keyword that indicates nothing is returned from the method. If the keyword is replaced by the name of a class (like int, boolean, myClass, etc.), then the method should return an object of that class.

public void myMethod() {
  // should return nothing
}

public String myOtherMethod() {
  // should return a string
}

Welcome to the forums!

On https://www.codecademy.com/courses/learn-java/articles/java-program-structure, it says that

Every Java program must have a method called main() .

Does this mean that every file in the complete program must have a main() method, or does this mean that in the whole program, which can be made up of many files, at least one of the files must have the main() method?

I am confused…

Welcome to the forums!

This means that there must be one main method in your entire program (which can be made up of many files).

1 Like

Wow, that was quick! Thanks! :slight_smile:

1 Like

What must one have in mind when composing a Java program, is there a set of systematic steps like in web development where we have 1. Head, 2. Body for linkages in web development?

Hello @tag4323858585

Looks like you are new to programming! You will learn all of this syntax in later lessons. But let’s do a little breakdown, by writing: public static void main(String[] args) { }, we defined a function. A function temporary stores a block of code to run later, you will learn about this in later lessons. But the ‘main’ method is not a regular method, in fact, it is an entry point. And entry point is where your code starts executing. It is where the program begins. Now the System.out.println("")'s job is to print a message to the console.

I hope you found that helpful!