by Dinesh Thakur Category: array
 
by Dinesh Thakur Category: array

Array is a group of related data items, that share a common name with same data type. An individual variable in the array is called an array element.

We can define an array name rollno to represent a set of roll no of a group of students. A particular value is indicated by a number called index number. An index number is present in brackets after the array name.



 
by Dinesh Thakur Category: array

Just as you can pass primitive type values to methods, you can also pass arrays to a method. To pass an array to a method, specify the name of the array without any square brackets within the method call. Unlike C/C++, in Java every array object knows its own length using its length field, therefore while passing array's object reference into a method, we do not need to pass the array length as an additional argument. For example: Suppose we have an integer array num containing 10 elements.

 
by Dinesh Thakur Category: array

One-dimensional array that uses a single index. Just like other languages like C/C++ one may think that Java might also have multidimensional arrays too, which are arrays that contain more than one index and can store information in multiple dimensions. But Java does not truly support multidimensional arrays. However, one can achieve the same functionality by declaring an arrays of arrays.



 
by Dinesh Thakur Category: array

Algorithm for Swap Elements of an Array:

 

step 1: read y

step 2: create two integer arrays a[],b[] of size y

step 3: initialize x=0

step 4: repeat through step-6 while (x < a.length)

step 5; read b[x]

 
by Dinesh Thakur Category: array

Algorithm for Removing duplicate elements from Array:

step 1: read y

step 2: create two integer array a[],b[] of size y

step 3: initialize c=0

step 4: repeat through step-6 while c less than a.length

step 5: read a[c]

step 6: c=c+1

step 7: initialize c=0

 
by Dinesh Thakur Category: array

Matrix addition means addition of respective positions. That is, element of 0th row 0th column of first matrix will be added with 0th row and 0th column of second matrix and placed in resultant matrix at 0th row and 0th column position. And this way all the element positions of first matrix are added with the respective positions of second matrix and stored in resultant matrix at the same position.

 
by Dinesh Thakur Category: array

With the release of version 1.5, Java introduced a new type of for loop known as enhanced or numerical for loop. It is designed to simplify loops that process elements of array or collection. It is useful when you want to access all the elements of an array but if you want to process only part of the array or modify the values in the array then use the simple for loop.

 
by Dinesh Thakur Category: array

The String object can be created explicitly by using the new keyword and a constructor in the same way as you have created objects previously. For example: The statement

 
by Dinesh Thakur Category: array

Algorithm for Sum and Average the Elements:

step 1: set sum=0

step 2: read arr_size

step 3: create an integer array arr[] of size arr_size

step 4: initialize i=0

 

Page 1 of 10

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article