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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:28:16+00:00 2026-06-11T17:28:16+00:00

for (Entry<String, Data> entry : list.entrySet()) { if(entry.getValue().getRoom() == 1){ if(entry.getValue().getName().equalsIgnoreCase(RED)){ entry.getValue().getPosition() // need

  • 0
    for (Entry<String, Data> entry : list.entrySet()) {
        if(entry.getValue().getRoom() == 1){
            if(entry.getValue().getName().equalsIgnoreCase("RED")){
                 entry.getValue().getPosition() // need to get the lowest free number
                 // between the range of 1-6
            } 
        }
    }

How to get the lowest free spot of the getPosition in this situation. getPosition values are between 1-6 and there are only one of each value Room = 1 and Name = RED.
For example if 1,3,4,6 exists in getPosition(with room=1 and name=red) then the output should be 2. That is the lowest number that is free in getPosition in the specific combination. Hope u can help me out.

  • 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-11T17:28:18+00:00Added an answer on June 11, 2026 at 5:28 pm

    Well, it sounds like the simplest approach would be something like:

    boolean[] taken = new boolean[7]; //(0-6 inclusive)
    // You were never using the key as far as I could see...
    for (Data data : list.values()) {
       if (data.getRoom() == 1 && data.getName().equalsIgnoreCase("RED")) {
           taken[data.getPosition()] = true;
       }
    }
    
    for (int i = 1; i <= 6; i++) {
        if (!taken[i]) {
            return i;
        }
    }
    
    // Do whatever you want if there are no free positions...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for (Entry<String, String> entry : map.entrySet()) { String delimiter = **; result = result.replace(delimiter
im working on this jquery data entry form in which i need a specific
I have a MultiMap and need the best possible way to get an EntrySet
I want to bind a textBox's data to a Dictionary<string,string> entry. I am trying
I have a NSMutableDictionary of NSMutableSets. Each set entry is a string, something like
In VS2008, you could enable right-margin marks by creating a string registry entry named
I have a List<string> in Model. When I write a html helper , I
I'm writing a program for some data entry I have to periodically do. I
How can I get a list of the order of tables? I have two
When a user clicks on a list I need a way to update MyCustomAdapter

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.