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 8829455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:50:13+00:00 2026-06-14T07:50:13+00:00

so i am working on comparing two arrays based on a users input. One

  • 0

so i am working on comparing two arrays based on a users input. One array is an int array, the other is a string. What i want to do is take a users input, compare the input to the first int array, then calculate the element within the same position of the string array. then print out my results based on the second array.
Like below i would input 12 then get bob or 21 then get andrea. Example code below. I have everything up to the comparison of the second array (i have the user input, finding it within the int array – the loop, but i just cant figure out the comparison to the second array)

int[] number = {12, 15, 19, 21}
String[] character = {bob, sally, james, andrea} 

would i just compare both the arrays then save it in a new variable:

number = character

then print the new variables value?

thanks for the help. i have been searching everywhere for this one. mainly spend a day and a half on this website.

  • 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-14T07:50:14+00:00Added an answer on June 14, 2026 at 7:50 am

    You do not need to compare anything to the second array: once you have the index of the matching element in the first array, simply use that index against the second array. That’s all there is to it!

    int[] number = {12, 15, 19, 21};
    String[] character = {"bob", "sally", "james", "andrea"};
    int userInput = ... // <<== You know how to do all that 
    for (int i = 0 ; i != number.length ; i++) {
        if (number[i] == userInput) {
            // Element at index i is matching:
            System.out.println(character[i]);
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compare two dates in PHP. One date is the date due,
Working with an array of dates (opening times for a business). I want to
Possible Duplicate: comparing two strings with comma seperated values I am working in C++,
I am working on a script to grade a user response by comparing two
I'm working on comparing two versions of a listview, for a settings form. I
My question to java folks is, when I am comparing two strings imageName=new String[20];
Im implementing a reminder app.There are two reminders (one for everyday and other for
How do we compare two NSInteger numbers ? I have two NSIntegers and comparing
I am currently working on comparing two complex objects of the same type, with
How can I take two images and compare them to see how similar they

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.