Skip to main content


An array is defined as a finite set of homogeneous elements. Finite means, there is specific number of elements in the array. Homogeneous means, all the elements in the array must have the same type. The general form of array declaration in Java is
Data type array name [];
Data type [] array name;
E.g. int a [];
int [] a;
After the declaration we have to allocate memeory for the array in Java. The "new" operator is used to allocate memory.

Eg: int a[]=new int[10]; will create an integer array with 10 elements
Note:In Java an integer variable will occupy 4 bytes of memory.
One imensional(1D) Array
A linear or 1D array is a list of finite number of similar data elements. Each element of array is identified by a subscript(index). The elements of the array are stored respectively in successive memory locations.In Java the subscript start from 0.
The number of elements in an array is called the length or size of the array. In general the length(number of elements) of an array is obtained from the formula
Length= UB-LB+1
UB is the largest index called upper bound and LB is the smallest index called lower bound.


Let A be a linear array. The elements are stored in successive memory locations. The address of the first location is called base address. Using the base address, the address of any element of a can be calculated as:
A[i] =base address+ (i)*size;
size is the size of each individual element in the array.
Consider an array A having the base address 1000 and size of each element is 4 bytes. To find the address of the third element we have
A [3] =base adress+ (3)*size
=1000+ (3)*4

Address of A[3] =1012.

Two Dimensional (2D) Arrays
A 2D M X N array is a collection of M X N data elements such that each element is specified by a pair of integers I and J called subscript. The element of A with row subscript I and column subscript J is denoted by A [I ] [J].
The element A[I ] [J] appears in row I and column J
Let A be a 2D array with M rows and N columns. The array will be represented in memory by a block of M X N sequential memory location. 2D array can be stored either by column major order or by row major order.

A[0][0] A[0][1] A[0][2]
A[1][0] A[1][1] A[1][2]
A[2][0] A[2][1] A[2][2]

Row Major Representation:

In the row major organization the address of the element A[i][j] is computed as follows:
base address+j *n* size + i* size
Column Major Representation:
In column major order the address of the element A[i][j] is computed as follows
base adrees+ i* m *size + j* size


Popular posts from this blog

KTU-FOSS LAB Solutions

Write shell scripts to show the following  ( you can write menu driven programs)
 Currently logged user and his logname ( logname)  Your current shell ( echo $SHELL)  Your home directory ( echo $HOME)  Your operating system type (echo $OSTYPE)  Your current path setting ( echo $PATH)  Your current working directory ( echo $PWD )  Show Currently logged  users ( w or who -H)      Show only the user name of logged users in the host ( users)      Details of last login ( last cek....where cek is the user id )  About your OS and version, release number, kernel version ( uname -a or  cat  /proc/version)  Show all available shells ( cat /etc/shells )  Show mouse settings (cat  /sys/class/input/mouse*/device/name )  Show computer CPU information       CPU details      ( cat /proc/cpuinfo | more )       Show information on  CPU architecture ( lscpu)       Number of Processor core ( nproc)  Show memory information       Memory details ( cat /proc/meminfo | more )       Display file system disk usage ( d…

Important Directories and Files

Important Directories
/bin                            holds the “essential” Linux commands and utilities /boot                          holds files required for boot process (kernel, vmlinuz, grub) /dev                            holds device files (hard drive, USB, CD-ROM, etc.) /etc                             holds system configuration files /etc/init.d                    holds scripts to start/stop network services /etc/rc.d                     holds system startup/shutdown scripts /etc/X11                      holds configuration files for X-windows /home                        holds user home directories (except for the root account) /lib                               holds system/shared library files /lost+found                holds files restored after system crash /mnt                            used as temporary mount point for CD-ROM, floppy, etc. /opt                              typically where large software applications are installed /proc                           holds kerne…

ER Diagrams to Table

REDUCING E-R DIAGRAM TO TABLE - A database which conforms to an E R diagram can be represented by collection of tables .For each entity set and for each relationship set in the database, we will create unique tables, which is assigned the name of the corresponding entity set or relationship sets . Each table has a no. of columns which have unique names. Each row in the table corresponds to an entity or a relationship.

REPRESENTATION OF STRONG ENTITY SET -Let E be a strong entity set with descriptive attributes a1, a2....aN . We represent this entity by table called E with N distinct columns, each of which corresponds to one of the attributes of E.

REPRESENTATION OF RELATIONSHIP SET - Let R be a relation ship set involving entity set E1,E2....En Let attribute(R) consists of 'm' attributes We can represent this relation ship set by a table called R with m distinct columns, each of which corresponds to one of the attributes in attribute (R) plus the primary key of E1..En.