Learn Java Programming - Class Introduction Tutorial

Опубликовано: 20 Октябрь 2024
на канале: Daniel Ross
1,504
27

What is a class? The truth is that there is no easy way to explain what a class is to someone who is learning the language. With that being said, a class is a template or blueprint from which objects are created. Okay, what is an object? An object is an instance of a class.
Confused? You should be. It is one of those catch 22 situations; you need to understand what a class is to understand an object, and you need to understand what an object is to understand a class. Now don't give up just yet, I promise that with a little time it will all make sense.
Throughout the tutorials we have have created many classes and the one thing they all have in common is the main method. Without that special main method, a class has no entry point; if we invoke (run) a class with no main using the java command line tool, we will get an error. Let's go ahead and do just that and then we will build on some more concepts.