0% found this document useful (0 votes)
47 views10 pages

Day2 Keywords

This document summarizes key concepts in Java programming including whitespace, identifiers, literals, comments, separators, keywords, data types, variables, and type conversion. It discusses that Java is a free-form language with no indentation rules. Identifiers are used for class, method, and variable names. Literals represent constant values. Comments are single-line or multi-line. Separators include semicolons. There are 48 keywords. Data types include primitive types like int, char, and boolean. Variables are declared with a type, identifier, and optional initializer. Type conversion can be implicit or explicit using casting.

Uploaded by

Addanki Asish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views10 pages

Day2 Keywords

This document summarizes key concepts in Java programming including whitespace, identifiers, literals, comments, separators, keywords, data types, variables, and type conversion. It discusses that Java is a free-form language with no indentation rules. Identifiers are used for class, method, and variable names. Literals represent constant values. Comments are single-line or multi-line. Separators include semicolons. There are 48 keywords. Data types include primitive types like int, char, and boolean. Variables are declared with a type, identifier, and optional initializer. Type conversion can be implicit or explicit using casting.

Uploaded by

Addanki Asish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Java Programming

White Spaces
Identifiers
Literals
Comments
Separators
Keywords
Data types and variables
Type Conversion
Whitespace
Java is a free-form language. This means that you do not
need to follow any special indentation rules.
Identifiers
Identifiers are used for class names, method names, and
variable names. An identifier may be any descriptive
sequence of uppercase and lowercase letters, numbers, or
the underscore and dollar-sign characters.
Literals
A constant value in Java is created by using a literal
representation of it. For example, here are some literals:
100 98.6 'X‘ "This is a test"
Comments
As mentioned, there are two types of comments defined by
Java. You have already seen two: single-line and multiline.
Single line comment (//……)
Multiline comment (/*…….*/)
Separators
In Java, there are a few characters that are used as separators.
The most commonly used separator in Java is the
semicolon.
; terminator
, seperator
. to separate package names
The Java Keywords
There are 48 reserved keywords currently defined in the
Java language.
Data Types, Variables
The Simple Types
Java defines eight simple (or elemental) types of data: byte,
short, int, long, char, float, double, and boolean.
These can be put in four groups:
• Integers This group includes byte, short, int, and long,
which are for whole-valued signed numbers.
• Floating-point numbers This group includes float and
double, which represent numbers with fractional precision.
• Characters This group includes char, which represents
symbols in a character set, like letters and numbers.
• Boolean This group includes boolean, which is a special
type for representing true/false values.
Integer :
Float :

Character: each character occupies 8 bits


Variables
The variable is the basic unit of storage in a Java program. A
variable is defined by the combination of an identifier, a
type, and an optional initializer.

Declaring a Variable
Type identifier [ = value][, identifier [= value] ...] ;
Ex:
int a, b, c;
int d = 3, e, f = 5;
byte z = 22;
double pi = 3.14159;
char x = 'x';
Type Conversion and Casting
to assign a value of one type to a variable of another type.
(target-type) value
There are two types of conversions
Implicit Conversion
Explict Conversion
Implicit Conversion: This is automatic lower datatype to higher
datatype conversion
Ex: int a=10; long b; b=a;
Explict Conversion: we have to do manually by using type
casting Higher datatype to lower datatype conversion.
Ex: int a=10;
byte b;
b = (byte) a;

You might also like