Array Contact

public class ArrayContact {

    public static void main(String[] args) {
        int[] pool = new int[]{9, 6, 3, 0, 8, 1, 7};
        int[] index = new int[]{5, 2, 4, 5, 1, 3, 0, 6, 3, 4, 1};
        String tell1 = "";//first method
        StringBuilder tell2 = new StringBuilder();//second method
        for (int i = 0; i < index.length; i++) {
            int value = index[i];
            tell1 += pool[value];//first method
            tell2.append(pool[value]);//second method
        }
        System.out.println("Telephone number (1st method) is : " + tell1);
        System.out.println("Telephone number (2nd method) is : " + tell2.toString());
    }
}

 

Scroll to Top