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

Notes-variables-Jan 23

Java is a widely used programming language for enterprise applications, internet-based software, and mobile devices, with over 3 billion Java-enabled devices in use. It is statically and strictly typed, requiring variable declaration before use, and supports various types of variables including local, instance, and static. The document also outlines rules for naming identifiers, lists valid and invalid examples, and introduces Java keywords and array declaration syntax.

Uploaded by

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

Notes-variables-Jan 23

Java is a widely used programming language for enterprise applications, internet-based software, and mobile devices, with over 3 billion Java-enabled devices in use. It is statically and strictly typed, requiring variable declaration before use, and supports various types of variables including local, instance, and static. The document also outlines rules for naming identifiers, lists valid and invalid examples, and introduces Java keywords and array declaration syntax.

Uploaded by

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

Why Java ?

Java is the preferred language for meeting many


organizations’ enterprise programming needs.

Java has become the language of choice for


implementing Internet-based applications and software
for devices that communicate over a network.

According to Oracle, more than 3 billion Java-enabled


cell phones, smartphones and handheld devices (such as
tablet computers) are in use.

Desktop Applications such as acrobat reader, media


player, antivirus, etc.

Web Applications such as irctc.co.in, javatpoint.com, etc.

Enterprise Applications such as banking applications.

Mobile

Embedded System

Smart Card

Robotics

Games, etc.
Variables in Java

Java is a statically typed programming language. It


means, all variables must be declared before its use. Java
is also a strictly typed language.
A variable is a container that holds the value while the
Java program is executed.
A variable is assigned with a data type.
Variable is a name of a memory location.
There are three types of variables in java: local, instance,
and static.
VARIABLE DECLARATION
datatype variablename;
Example:
int a;
float b;
Initialization of variable:
datatype variablename=value;
Example:
Int a=50;

Java-Identifiers

Rules for Naming an Identifiers

VALID IDENTIFIERS
Examples:
TestVariable
testvariable
a
i
Test_Variable
_testvariable
$testvariable
sum_of_array
TESTVARIABLE
jtp123

INVALID IDENTIFIERS
Examples:

Test Variable (We can not include a space in an identifier)


123hello (The identifier should not begin with numbers)
hello+word ( The plus (+) symbol cannot be used)
a-student ( Hyphen symbol is not allowed)
hello_&_world (ampersand symbol is not allowed)
Java'tpoint (we can not use an apostrophe symbol in an
identifier)

JAVA KEYWORDS
Java keywords are also known as reserved words.
Keywords are particular words that act as a key to a code. These
are predefined words by Java so they cannot be used as a
variable or object name or class name.
One Dimensional Array in Java

Syntax to Declare an Array in Java

dataType[] arr;
dataType []arr;
dataType arr[];

array RefVar = new datatype[size];

You might also like