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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:25:56+00:00 2026-06-14T08:25:56+00:00

UPDATED CODE I’m trying to figure out a way to count how often one

  • 0

UPDATED CODE

I’m trying to figure out a way to count how often one value appears in an ArrayList.

System.out.println("Hand 1, Number of Clubs: " 
              + hands[0].frequency(hands[0], Card.Suit.CLUBS));

So in the above case i want to count how many “Clubs” are in hands[0].

public int frequency(Hand c, Suit suit){
    int count = 0;
    if(suit == suit) //need this to be "If suit (club) is present, count++)
            {
             count++;
            }    
    return count;
}

I’m drawing a blank…. If i change the method type to ArrayList then i cannot return “count”

hands[0] is created by:

    Hand[] hands = new Hand[4];
    for(int i=0; i<hands.length; i++) {
       hands[i]=new Hand();
       }
       for(int i=0; i<=Deck.size()+8; i++) {
          for(Hand hand:hands) {
             hand.addSingleCard(Deck.deal());
           }
       }
  • 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-14T08:25:57+00:00Added an answer on June 14, 2026 at 8:25 am

    Collections.frequency

    You have this feature already available from Collections class, in the frequency method.

    public static int frequency(Collection<?> c, Object o)
    

    That will return the number of occurrences of a specific object inside a collection.

    Mind that without providing a vaild equals method this won’t work or at least won’t work with the equality you have in mind, since Java does’t know your meaning of equality.

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

Sidebar

Related Questions

Here's my updated code trying to get my form to send me the email.
(updated code with serialization functions - still redirects to /failedRedirect) I'm trying to get
I have updated code for ActiveX functionality which already installed on client(in their Windows
EDIT : Scroll down to see the updated code. I would like to build
I updated my code with string dates created with new Date and added back
I updated my code like Andro wrote about to me: public class ZiiziiActivity extends
Okay I have updated my code quite a bit. I am getting a new
Okay I have updated my code a little, but I am still not exactly
I've updated some code to use the Ajax Control toolkit 0911 beta and for
UPDATE I have updated my code in response to @MichaelRushton comments. I am now

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.