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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:34:09+00:00 2026-06-08T03:34:09+00:00

In my program, a Die (dice for embroidery) is a class with different fields.

  • 0

In my program, a Die (dice for embroidery) is a class with different fields. One of them is of the type String and it is called haveIt. So, if the user of the program enters the word “Yes” on the haveIt field, he should be able to track a list of all the Dies he has, on the myInventory list.

How do I do this? Should I create the myInventory ArrayList<Die> on the fields and constructor of my Contoller class or should I built it inside a special method in that class?

I have tryed everything and nothing works. But I am really new on this.

Here is my last attempt, creating a loop to create the new ArrayList<Die> (that has “Yes” on the haveIt field) from a special getMyInventory method in my Controller class:

public ArrayList<Die> getMyInventory(Die anyDie) {
    for (int counting = 0; counting <  
diesBigList.Count ; counting++); 
        {
        if 
(((Die)diesBigList[counting]).doIHaveIt.contains("Yes")) 

myInventory.add(diesBigList[counting]);

            return myInventory; 
        }   
}

It does not compile. It tells me that the result should be an Array type but it is resolved as ArrayList… (and I do not comprendo that).

Thanks in advance.

  • 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-08T03:34:11+00:00Added an answer on June 8, 2026 at 3:34 am

    Your missing a return statement. What if this is never true?

    if (((Die)diesBigList[counting]).doIHaveIt.contains("Yes")) 
    

    you never reach your return statement

    Here is the answer

    public ArrayList<Die> getMyInventory(Die anyDie) {
     ArrayList<Die> myInventory = new ArrayList<Die>();
        for (int counting = 0; counting <  diesBigList.Count; counting++) {
            if (((Die)diesBigList[counting]).doIHaveIt.contains("Yes")) {
                   myInventory.add(diesBigList[counting]);
            }   
        }
                return myInventory; 
     }
    

    Also there could be a problem with this: diesBigList.Count I have no idea where you got that object or what it’s methods looks like but I presume in my code your making that call correctly.

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

Sidebar

Related Questions

I wrote a program that rolls a die with a user-specified number of sides.
The throw of a die is a popular program in Java, public class Die
For the sample program: type public MyClass(reasonForLiving:string) = member x.ReasonForLiving with get() = reasonForLiving
I wrote a program in java that rolls a die and records the total
Program returns an error of, expected PWideChar instead of string procedure TForm1.Button1Click(Sender: TObject); var
The following program : public class SimpleCounter extends HttpServlet { int counter=0; @Override protected
I need to modify an existing Perl program. I want to pipe a string
Consider the following C++ program: #include <cstdlib> // for exit(3) #include <string> #include <iostream>
When I use exit or die , it kills the entire program. foreach my
I have seen some code do this: if(something){ echo 'exit from program'; die; }

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.