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

  • Home
  • SEARCH
  • 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 6052343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:55:06+00:00 2026-05-23T07:55:06+00:00

I have a Project class that holds a name and various other attributes. Everytime

  • 0

I have a Project class that holds a name and various other attributes. Everytime a new Project is made it is added to an ArrayList.

ArrayList<Project> mProject = new ArrayList<Project>();

I have most of the code in a different question. I don’t feel like I should ask it there as it has a different question on it. But if you want to check out more of the code it’s here:

Can I use a method from a different class that I have added to an ArrayList?

And here is where I’m stuck. This is the first time I’ve used this type of loop before and I don’t know what’s going on. I have seen tutorials just pass over this loop with a “you should know what happens here” attituded. So if you could explain this loop that would be great also.

And on to the code:

System.out.println("Select one of the fallowing projects:");    
for (Project proj : mProject){
    int i= 1;
    i++;
    System.out.println( i + ": " + proj.returnName());
}

My output is this:

Select one of the fallowing projects:

2: Greg

2: Mike

It looks like it’s not going though the code. So I’d love an explanation or a tutorial with this loop. Thanks.

If I use a regular loop how whould I go about using the methods from the mProject arraylist?

for ( int i = 0; i<= mProject.size() ; i++){
    Project proj = mProject;// This won't compile. 
        if (choice ==  proj.returnName()){                  
        }
}
  • 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-23T07:55:06+00:00Added an answer on May 23, 2026 at 7:55 am

    If you move the int declaration out of the loop it will increment as you would expect, it is getting reassigned every time:

       int i= 1; 
        for (Project proj : mProject){
          i++;
          System.out.println( i + ": " + proj.returnName());}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project I have a class that is inherited by many other classes.
This is for a school project. I have a Query<E> class that holds an
I have inherited a project that has class libraries written in VB.NET, some of
I have all my views in a project inheriting from a ViewBase class that
In the project I'm working on now, we have base Entity class that looks
I have a class library project that references the version 4.1 Microsoft.Practices.Common dll. I
Let's say I have a project that is a class library. I have a
I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I
We have two projects that are both class libraries. Project 1 is a VS
I have an ASP.NET VB.NET web project that references a VB.NET class library. I

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.