Here is a guide for the beginners to understand the java basics concepts and syntax.
Anything which has different states and behavior can be classified into Object. For instance, a cat will have states such as breed, color as well as behavior like pouncing, eating and so on.
It is nothing but the template that talks about the behavior and state supported by the objects belonging to that class.
There can be several methods in a class wherein the programmer can write the logic, manipulate the data and implement an action.
Every object has its unique set of instance variables. Also, the state of the object is created through values assigned to these instance variables.
Before starting with the first Java program, there are few things that should be considered.
Same word types in uppercase and lowercase will mean different in Java.
When defining the class name, the first letter should be in Uppercase. In case there are several words, each inner word should be in Uppercase.
Unlike Class Names, all Method Names should start with the Lower Case letter. However, if there are several words used to form the Method Name, then every inner word’s first letter should be in Upper Case.
Program File Name
Program File and Class Name should match exactly
Public Static Void Main
The Program processing in Java starts from the main () which becomes the obligatory part of every Java Program.
There are several things to consider about the Identifiers such as:
All identifiers should start with a letter, underscore, and currency character
Post first character, identifiers can have several other combinations of characters
One cannot use a keyword as an Identifier
There are legal and illegal Identifiers
Identifiers are case sensitive
There are several ways to modify methods, classes with the help of modifiers in Java.
There are three types of variables in Java
- Local Variables
- Class Variables
- Instance Variables