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.
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.
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
}
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?
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?
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.