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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:58:32+00:00 2026-05-20T00:58:32+00:00

public void collect( int ordNum ) { Basket b = new Basket(ordNum); for (Basket

  • 0
  public void collect( int ordNum )
  {
       Basket b = new Basket(ordNum);
       for (Basket b : conveyerBelt) { // line 4
           readyCollected.add(b);
       }
  }

What I’m trying to do with this method is search through an ArrayList for a orderNum. When I find it, I want to add the orderNum i entered in to the readyCollected. Problem: I get an error message on line 4.

Was wondering if you can guys can help me implement this method.

BTW, the conveyerBelt already contains Basket with an order number. So lets say the conveyerBelt contains Basket with order number 3, and I enter in 3, I want it to add Basket to Arraylist readyCollected containing order number 3.

  • 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-05-20T00:58:32+00:00Added an answer on May 20, 2026 at 12:58 am

    I’m guessing your error is that conveyerBelt is not Iterable. To use the foreach construct, you must make sure the object you are Iterating over implements Iterable.

    http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.14.2

    Excerpt:

    The Expression must either have type Iterable or else it must be of an array type (§10.1), or a compile-time error occurs.

    The scope of a local variable declared in the FormalParameter part of an enhanced for statement (§14.14) is the contained Statement

    The meaning of the enhanced for statement is given by translation into a basic for statement.

    If the type of Expression is a subtype of Iterable, then let I be the type of the expression Expression.iterator(). The enhanced for statement is equivalent to a basic for statement of the form:

    for (I #i = Expression.iterator(); #i.hasNext(); ) {
    
            VariableModifiersopt Type Identifier = #i.next();
       Statement
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public void openOptions() { Intent intent=new Intent(this,Game.class); //intent.putExtra(razmer, level); startActivity(intent); // Intent intent=new Intent(this,Options.class);
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Init(); backthread tr=new backthread(); tr.execute(0,0,0); } backthread
public void GrabData() throws IOException { try { BufferedReader br = new BufferedReader(new FileReader(data/500.txt));
public void EditAndSave(String fileName) { Bitmap b = new Bitmap(fileName); /** * Edit bitmap
I've this: public class GpsUpdate extends Observable implements LocationListener { private int x_position; private
I'm new to java and I'm trying to run a method once a button
I have a method in engine i'm using (andengine) : public final void setText(String
I found this piece of code inside System.Web.ISAPIRuntime using Reflector public void DoGCCollect() {
i am trying to collect some values in int array,which are from the web
public void printList( ){ Node<E> p ; System.out.printf( [ ) ; for ( p=head.next

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.