public class ParallelArray { public static void main(String[] args) { int[] id = {1002, 423, 786}; String[] name = {"John Doe", "Mary Jane", "Peter Pan"}; String[] dept = {"Deli", "Pharmacy", "Produce"}; double[] pay = {12.50, 13.75, 9.78}; /* ---------------------------------------------- Print the information in the parallel arrays ---------------------------------------------- */ System.out.println("ID Name Department Pay"); System.out.println("---- ---------- ---------- -----"); for ( int i = 0; i < id.length; i++ ) { System.out.printf( "%04d ", id[i] ); System.out.printf( "%-10s ", name[i] ); System.out.printf( "%-10s ", dept[i] ); System.out.printf( "%5.2f" , pay[i] ); System.out.println(); } } }
$ java ParallelArray ID Name Department Pay ---- ---------- ---------- ----- 1002 John Doe Deli 12.50 0423 Mary Jane Pharmacy 13.75 0786 Peter Pan Produce 9.78
Add Contents Of One ArrayList to Another
Array Of ArrayLists
ArrayList Adding Elements
ArrayList Remove Elements
ArrayList Remove Elements By Name
Basic HashMap Example
Basic HashSet Example
Basic TreeSet Example
Binary Search On Array
Calculate The Intersection Of Two Sets
Clone An ArrayList
Cosequential Processing
Count Duplicated Items In A List
Count Unique Characters In A String
Double Ended Queue
Find Minimum and Maximum Element in a Set
Finding The Longest String In A String Array
Initialize An ArrayList
Iterate Through A HashMap
Iterator Example
ListIterator Example
Parallel Arrays
Populate List With Comma Seperated Sting
PriorityQueue Sorted By String Length
Read Elements From A HashSet Using An Iterator
Read Elements From An ArrayList Using An Iterator
Simple Way To Print The Contents Of An Array
Sort An ArrayList Using A Comparator
Sorting A HashMap Using A TreeMap
Sorting A List Of Objects By Date
Stack Example
Swap Two Elements In An ArrayList