Professional Documents
Culture Documents
11 (A) - Arrays Application-I
11 (A) - Arrays Application-I
11
Arrays Application-I
Objective:
To implements the concept of one dimensional Array.
Scope:
Arrays are special data types that let us store specified number of variables from the same type using one
variable name. Arrays are an indexed data type, which means they are storing different elements discrim-
inating between them using unique index for each one. Declaring and using an array in Java is similar to
declaration of any variable; you have to specify data type and name, in addition to this, you have also to
specify the length of the array before using it.
Exercise 1:
Write a program using arrays to solve the problem. The problem is to read 10 numbers, get the average of
these numbers, and find the number of the items greater than the average.
Exercise 2:
Count the occurrences of each letter in the array. To do so, create an array, say counts, of 26 int values,
each of which counts the occurrences of a letter. That is counts[0] counts the number of a’s, counts[1]
counts the number of b’s, and so on.
Exercise 3:
Write a program that reads 10 numbers in an array, write a method which will return the sort array.
Homework:
1. (Eliminate duplicates) Write a method that returns a new array by eliminating the duplicate values in
the array. Write a JAVA program that reads in at least ten integers, invokes the method, and displays
the results.