Sun Microsystems have divided Java into 3 parts-Java SE(Standard Edition), Java EE(Enterprize Editon), and Java ME(Micro Edition). We are studying Java SE.
Lets start with Comments
Comments:
Writing comments is a good programming habit. Comments are description about the features of a program. This means that whatever we write in a program should be described using comments. This comments make the program more understandable.There are 3 types of comments:
- Single Line Comments
- Multi Line Comments
eg: /* this is
Multi line comment */
- Java Documentation Comments. (usefull for creating Java API document)
Documentation
comment */
Variables:
The Java programming language defines the following kinds of variables:
- Instance Variables (Non-Static Fields) These are the variables which are initialized every time the object is created. For every object in a class JVM allocates memory to Instance variables. Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the
static
keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object). - Class Variables (Static Fields) A static or class variable is any field declared with the
static
modifier; this tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated. - Local Variables These are the variables created for temporary use. Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example,
int count = 0;
). The scope of these variables is until the end of method or a block in which they are declared. There is no special keyword designating a variable as local. - Parameters These are the variables passed to a method.