i
Understanding Requirement: Why Java
Why Java is important to the Internet
Java On Linux
First Java Program
Java Virtual Machine Architecture
Class Loading Process by Class Loaders
Role Of Just In Time Compiler
Execution Engine
Data Types
Variables
Arrays
Operators
Arithmetic Operations
Shifting Operators
Logical Operators
Control Statements
Object Oriented Paradigms
The Three OOP principles
Looping Statements
JAVA Class Fundamentals
Command Line Arguments
Static Initialize
Creating an Object
Instance Variable Hiding
Overriding and Overloading of methods
Understanding The Access Controls
Nested And Inner Classes
Dynamic Method Dispatching
Abstract Classes
Using Final To Prevent Overriding & Inheritance
Garbage Collection
Defining a package
Understanding Classpath
Access Protection
Importing packages
Defining and Implementing An Interface
Abstract classes vs Interfaces
Generics
Annotations
Varargs
Foreach
Fundamentals Of Exception Handling
Types Of Exceptions
Learning exception handling, try-catch, multiple catch clauses
Nested Try Statements
Throw, Throws and Finally
Custom Exceptions
Java Thread Model
Creating A Thread
Context Switching
Synchronization: Methods And Statements
Inter-thread Communication
In Java we generally have three main types of control statements: Conditional, Looping and Unconditional.
Conditional control statements allows program to choose an alternative way according to some condition. There are two different terms for such statements: decision-making statements and selection statements.
One of the example of conditional control statement is if statement, which looks like this:
But we also might want to have statement which chooses one between two alternatives, for example we want to print “EVEN” if number is even and “ODD” if it is odd. For this we should use if-else statement, which looks like this:
In else block we can have additional conditional statement and it is called if else-if statement
There is another conditional statement switch which allows us to choose a way between multiple statements. Switch helps us to avoid multiple nested if-else blocks. Below is the syntax of switch statement.
There are few points we should know about switch statement:
Based on the switch statement’s argument, proper case value will be selected and then executed.
If there is no case which matches argument of switch, then the default case will be executed.
It is up to developer to write a break statement as a last command of each case statement. But if there is no break at the end of each statement and it somehow will happen that next statement also applies, both statements will run together.
Don't miss out!