Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java


Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

Variable in Java
Previous Home Next


Identifiers represent names which can be assigned to variables, methods, and classes to uniquely identify them. In java you can be creative in naming identifiers, but there are some limitations such as, all Java identifiers are case-sensitive and must begin with a letter, an underscore (_), or a dollar sign ($). Letters include both upper and lowercase letters, identifier characters can include the numbers from 0 to 9 and finally we cannot use Java defined keywords as identifiers.

For e.g. _shashi7, $r4remployee, programmer are some valid identifiers.


Literals are the constant values that are used in a program. These can include integers, floating-point numbers, characters, boolean and string values. Following are the examples of literals :

  • Integer Literals: 2, 3, -4, 5
  • Floating point Literals: 3.45, .0987, 943.45
  • Character Literals: 'h', 'k','1', '2'
  • Boolean Literals: true, false
  • String Literals: "shashi", "r4r", "12343"

Variable in Java

A variable may be defined as a storage location in memory for storing different data types. Thus, every variable has a type so we can declare a variable as :

  • int sum;
  • double sum;
  • char name;
Rules For Declaring Variables
  1. A variable name is decalared with a letter at begining and then can be a sequence of letters and digits.

  2. Symbols like + or @ cannot be used inside a variable name and also there can't be any space in variable name.

  3. All characters in the variable are case sensitive and length is essentially unlimited.

  4. You cannot use java keywords as variable names.

Assignment and Initialization

After you declare a variable you must initialize it explicitly, as uninitialized varibale can never be used.

int number;    // this is declaration
number=10;    // this is assignment

In java you can declare a variable and assigned it value upon declaration, i.e. intialization of variable

int number=10;     // this is initialization

You cannot declare two varibles of same name in the same scope.

Previous Home Next