UNIT-1
Data Types
Various data types used in Java are byte, short, int, long, char, float, double and
boolean.
EXAMPLE
Java Program [[Link]]
/*This program introduces use of various data type in the program*/
class DatatypeDemo
public static void main(String args[])
byte a=10;
short b=10*128;
int c=10000* 128;
long d=10000*1000*128;
double e=99.9998;
char f='a';
boolean g=true;
boolean h=false;
[Link]("The value of a=: "+a);
[Link]("The value of b=: "+b);
[Link]("The value of c=: "+c);
[Link]("The value of d=: "+d);
[Link]("The value of e=: "+e);
[Link]("The value of f=: "+f);
f++;
[Link]("The value of f after increment=: "+f);
[Link]("The value of g=: "+g);
[Link]("The value of h=: "+h);
Output
The value of a=: 10
The value of b=: 1280
The value of c=: 1280000
The value of d=: 1280000000
The value of e=: 99.9998
The value of f=: a
The value of f after increment: b
The value of g=: true
The value of h=: false
[Link]
JavaDoc Comments
Javadoc is a convenient, standard way to document your Java code. Javadoc is
actually a special format of comments. There are some utilities that read the
comments, and then generate HTML document based on the comments. HTML
files give us the convenience of hyperlinks from one document to another.
There are two types of Javadoc comments -
• Class level comments
• Member level comments
The class level comments describe the purpose of classes and member level
comments describe the purpose of members.
The Javadoc comments start with /** and end with */ For example
/** This is a Javadoc comment statement*/
Class Level Comments
The class level comments provide the description and purpose of the classes. For
example - /**
*@author XYZ
* The Employee class contains salary of each employee the organization
*/
public class Employee
//Employee class code
Member Level Comments
The member level comments describe the data members, methods and
constructors used in particular class. In this type of comments special tags are
used to describe the things. The most commonly used tags are -
The example of member level comments for the Employee class is as shown
below
public class Employee
private int amtSalary;
public Employee()
[Link]=0;
public int getAmtSalary()
return salary;
public void setAmtSalary(int No_of_Days_Worked, int Payscale)
[Link]=No_of_Days_Worked* Payscale;
}
Along with the above mentioned tags some HTML tags can also be included in
Javadoc comments. For example, we can use<table><img> tags in Javadoc. Also,
we can include special tags like < in the Javadoc. Some words like true, false
and null can also be included in Javadoc.