DEV Community

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

Posted on

4 3

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)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay