Education Menu

 

Features Menu

 

Additional Menu

 

Now Online

We have 105 guests online
 

@edulanka

 

Follow US

Twitter You Tube Google Plus
Pinterest Facebook EduLanka Blog

 

Information Zone

eduLanka Sinhala

Welcome to eduLanka.LK, Largest online education web site in Sri Lanka & most popular educational web site among Sri Lankan students. EduLanka, Best nonprofit & educational website is provided large numbers of online lessons, education related course information, teachers information, E books, examination result alerts, goverment job alerts, tuition class information, career guide for school leavers and more resources related to education in Sri Lanka. Edulanka provides education related resources from primary education, O-Level & A-Level education, University & Postgraduate education and vocational training education.

EduLanka IDN Domains http://එඩියුලංකා.ලංකා http://எடியுலங்கா.இலங்கை


jobs Mathematics SLAS Exam Dharma Education Results



 

Inside Online School

Share Us

Home Page Information Technology Java Programing (ජාවා වැඩසටහන්කරණය)

Java Complete Array Example
Wednesday, 09 March 2011 08:35

Java Array Example (Complete Array program)

Java Programing language Array program easy to identify and manupulate. Create Array in Java with any data type, Insert element into Array, Fing a element from Array and remove element from array. In this program, We used Terminal IO package to input value from key board instead of using BufferedReader class. Terminal IO package and all things related to this sample array program included zip file available to download.

This Java array program is compiled using JDK 1.5 and lower versions.

 

/*eduLanka Online education web site of Sri Lanka -------- w w w . e d u L a n k a . L K ------------

  java programs for University students - who follow courses  -  BIT  -  SLIIT and more
find more lessons in http://www.edulanka.lk This e-mail address is being protected from spambots. You need JavaScript enabled to view it
this programs under GNU licence
*/


import java.io.*;
import TerminalIO.*;

class ArrayApp{
public static void main(String[] arg){

KeyboardReader input=new KeyboardReader();
int i;
System.out.println("-------------------------------------------------");
System.out.println("---------http://www.eduLanka.lk-----------------");
System.out.println("-------------------------------------------------");
int n=input.readInt("How many elements? ");
System.out.println(" ");
int[] arr=new int[n];

for(i=0;i<n;i++){
System.out.print("Enter "+(i+1)+"th Element : ");
arr[i]=input.readInt();
}
System.out.print("\nAfter insert, elements are ");
for(i=0;i<n;i++)
System.out.print(arr[i]+" ");




int j, searchkey;

searchkey=input.readInt("\n\nenter element to search : ");
for(j=0;j<n;j++){
if(arr[j]==searchkey)
break;
}
if(j==n)
System.out.println("SORRY! Your choise is not in the List");
else
System.out.println("Found!!! --> "+(j+1)+" <-- Position of the list");


int k;
int delkey=input.readInt("\nenter element to delete: ");
for(i=0;i<n;i++){
if(arr[i]==delkey)
break;
}

if(i==n)
System.out.print("SORRY! Your element is not in the list");

else{
for(k=i;k<n-1;k++)
arr[k]=arr[k+1];
n--;
}


System.out.println("\nRest elements are : ");
for(i=0;i<n;i++)
System.out.print(arr[i]+" ");

System.out.println(" ");
System.out.println("-------------------------------------------------");
System.out.println("---------Thankyou, This e-mail address is being protected from spambots. You need JavaScript enabled to view it ------------");
System.out.println("-------------------------------------------------");
System.out.println(" ");

}
}





Download Complete this Program

Last Updated on Wednesday, 09 March 2011 09:05
 

Add comment

Add comments relevant to this Article. මෙම ලිපියට අදාලව පමණක් අදහස් එකතු කරන්න.


Security code
Refresh

14.jpg

Download Toolbar

 
 

Most Popular Articles

Latest Articles

Copyright © 2005 - 2016 (ඉස්කෝලේ) eduLanka Online Education School of Sri Lanka