2:22 am - Tuesday March 28, 2017

To Insert Number using array Concept

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

In this tutorial you will learn how to INSERT ELEMENT TO THE ARRAY. Method with Example Program.


public class Array {
public static void main(String[] args) {
int[] a = new int[7];
a[0] = 0;
a[1] = 1;
a[2] = 2;
a[3] = 3;
System.out.print(“Before Insertion:”);
for (int i = 0; i <= 3; i++) { System.out.print(a[i]); } System.out.println(""); System.out.print("After Insertion:"); a[4] = 4; a[5] = 5; a[6] = 6; for (int i = 0; i < a.length; i++) { System.out.print(a[i]); } } } [/java] Output

Before Insertion:0123

After Insertion:0123456

EXPLANATION:


Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection’s iterator.

BACK

Filed in: Java Examples

Comments are closed.