Flow Control
There are four basic flow controls in java,
- Decision-making statement -(if, if-else, if else if, nested if)
- Iteration statement - (for, while, do-while)
- Jumping statement -(break, continues, return, etc)
- Branching statement -(switch)
Loop
- Initialization -(Starting point)
- Condition -(Ending point)
- Operation -(Next Phase)
- Body -(repeat statement)
Syntax for loop
for (Initialization; Condition;
Operation)
{
…......body..........
}
Array
An array is a derived data type that is used to make a group of data of a similar type under a unique name. Each and every element of an array have a position value known as index/indexing. The number surrounded within [] is known as sub-script, it is used to
- To specify dimensions
- To access the required element
Type of Array
- One dimension array
- Multi dimension array
Example:-
Int arr[] = new int[size];
String name[] = new String[size];
In
java and C/C++ array have a difference, in
C/C++ array no option to declare in variable in “[]”
C/C++ :- int arr[ variable ] “\not possible/”
For example
int size =10;
int arry[size]; not possible
In java array have fully dynamic array have more option to declare any type;
For example:-
int size =20;
int arr[] = new arr[size] is possible
No comments:
Post a Comment