DEV Community

Cover image for Java array: find the contact number of a person
Biplob Hosain Sheikh
Biplob Hosain Sheikh

Posted on

Java array: find the contact number of a person

package com.java_android.android;

import java.util.Scanner;

public class Android {
    public static void main(String[] args) {

        String[] name = {"amir", "salman", "shahrukh", "saif", "kamal"};
        int[] number = {1576544, 2355778, 378467, 4556776, 584669};

        for (int i = 0; i < name.length; i++) {
            System.out.println(name[i]);
        }
        System.out.println("enter your name");
        Scanner scanner = new Scanner(System.in);
        String inputName = scanner.next();
        for (int j = 0; j < name.length; j++) {
            if (inputName.equals(name[j])) {
                System.out.println(number[j]);
            }
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)