0% found this document useful (0 votes)
8 views

JavaDoc Comments

The document discusses Java data types and Javadoc comments. It introduces common Java primitive data types like byte, short, int, long, char, float, double and boolean. It then provides a sample Java program showing the declaration and usage of these data types. The document further explains what Javadoc comments are and the two types - class level comments and member level comments. It provides examples of commenting a class and its members using Javadoc tags like @author, @param and @return.

Uploaded by

Rayna Ezhil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

JavaDoc Comments

The document discusses Java data types and Javadoc comments. It introduces common Java primitive data types like byte, short, int, long, char, float, double and boolean. It then provides a sample Java program showing the declaration and usage of these data types. The document further explains what Javadoc comments are and the two types - class level comments and member level comments. It provides examples of commenting a class and its members using Javadoc tags like @author, @param and @return.

Uploaded by

Rayna Ezhil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

UNIT-1

Data Types

Various data types used in Java are byte, short, int, long, char, float, double and
boolean.

EXAMPLE

Java Program [DatatypeDemo.java]

/*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;

System.out.println("The value of a=: "+a);

System.out.println("The value of b=: "+b);

System.out.println("The value of c=: "+c);

System.out.println("The value of d=: "+d);


System.out.println("The value of e=: "+e);

System.out.println("The value of f=: "+f);

f++;

System.out.println("The value of f after increment=: "+f);


System.out.println("The value of g=: "+g);

System.out.println("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

https://www.poriyaan.in/paper/object-oriented-programming-76/
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()

this.salary=0;

public int getAmtSalary()

return salary;

public void setAmtSalary(int No_of_Days_Worked, int Payscale)

this.salary=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 &lt in the Javadoc. Some words like true, false
and null can also be included in Javadoc.

You might also like