• iconJava Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Java Constant

Constant is an identifier whose value can not be changed.

int x=10;

10 is a constant
x is variable
int is a datatype

In java language these constants are classified into following types
1.Numerical constants
2.Character constants

Numerical Constants:
Numerical means numbers .these are classified into 2 types
1.Integer constants
2.Real constants

Integer Constants:
Integer constants menas + or - numbers.
int x=10;
int y=-10

Real Constants:
Real constants means floating values or decimal values.
float x=10.0;

Character Constants:
These are classified into following types
1.Single character constant
2.String character constant

Single Character Constant:

If any character or symbol or number enclosed with single quotation.
char x='a';
char x='2';
char x='@';

String Character Constant:

Group of characters or symbols or numbers enclosed with double quotation.
String s1="abc";
String s2="@##$";
String s3="123";

MSK TechnologiesTrainings