Introduction to Classes

Let's learn about classes in Java!

We'll cover the following...

Recap

Since the Hello, World! program, we have been ignoring a couple of repeating lines in all of the Java codes we have seen so far. So, how long are we going to ignore this elephant in the room?

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

We only discussed the fact that line 5 is used to print Hello World! on the screen. But what about the rest of the lines?

Formally, the first line is constructing a class for the HelloWorld program, whereas the third line describes a Java method by the name of main.

What is a class?

Is it the same as the trigonometry class you had at school? Not at ...