Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9305169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:52:11+00:00 2026-06-18T23:52:11+00:00

I have no idea if I’m coding this efficiently, or even correctly, but I

  • 0

I have no idea if I’m coding this efficiently, or even correctly, but I want to input a name, address, and phone number. I then want to have input find a match from the input array, and use that same index number to print the corresponding information.

import java.util.*;

public class NameAddress {

    public static void main(String[] args) {

        Scanner ui = new Scanner(System.in);
        System.out.println("Welcome to the name collecting database");
        String []names = new String[5];
        String []address = new String[5];
        String []phone = new String [5];
        int count =0;

        while (count<=5)
        {
            System.out.println("Please enter the name you would like to input");
            names[count] =ui.next();
            System.out.println("Name has been registered into Slot "+(count+1)+" :"+Arrays.toString(names));
            System.out.println("Please enter the address corresponding with this name");
            ui.nextLine();
            address[count] = ui.nextLine();
            System.out.println(names[count]+" has inputted the address: "+address[count]+"\nPlease input your phone number");
            phone[count]=ui.nextLine();
            System.out.println(names[count]+"'s phone number is: "+phone[count]+"\nWould you like to add a new user? (Yes or No)");

            if (ui.next().equals("No"))
            {
                System.out.println("Please enter a name to see matched information");
                String name = ui.next();
                if(name.equals(names[count]))
                {
                    System.out.println("Name: "+names[count]+"\nAddress: "+address[count]+"\nPhone: "+phone[count]);
                }
                count=6;
            }
            count++;
        } 
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:52:12+00:00Added an answer on June 18, 2026 at 11:52 pm

    if(name.equals(names[count])) will work only if the name user is searching is at the current index of names. So you have to check every item in the array to determine whether it exists in the array. You can do this:

    int itemIndex = Arrays.asList(names).indexOf(name);
    if(itemIndex>=0) // instead of if(name.equals(names[count]))
    {
        // rest of the codes; use the itemIndex to retrieve other information
    }
    else
    {
        System.out.println(name + " was not found");
    }
    

    Or manually loop over the names array as others showed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make phone based textbox in my html-page. someone have idea how
This could be a duplicate question, but I have no idea what search terms
I want to use TextArea as an inputStream.Anyone have idea how this can be
I want do some other item stacking but i dont have idea how simple
anyone have idea how to solve this problem counts the number of occurrences of
I have no idea why this is happening. The error I get is the
I have a basic idea of HTML. I want to create the download link
In fact I have Idea about the exception handling. But while facing the interview
I have converted svg to image using Raphael.js , canvg and jquery. But want
i want to implement comet in php... i have idea about how ajax works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.