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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:07:52+00:00 2026-06-01T17:07:52+00:00

I’m just starting with Java and I’m having trouble with the following code. I

  • 0

I’m just starting with Java and I’m having trouble with the following code. I was using something like this to call the non-static apply method from a static method, but I dont think its very efficient. I set an array list of the rules that need to be applied but I can’t get it to work.

    ClassificationRule rules = new RuleFirstOccrnc();
    ClassificationRule rules1 = new RuleOccrncCount();
    rules.apply(aUserInput);
    rules1.apply(aUserInput); 

I’m getting this error when trying to call the apply() method from ClassificationRule “The method apply(String) is undefined for the type ArrayList”. Any help would be greatly appreciated!

package tweetClassification;

import java.util.ArrayList;

public class PrioritRuls {

    //Set of rules to be applied
    final static ArrayList<ClassificationRule> rulesA
        = new ArrayList<ClassificationRule>();

    static{
        rulesA.add( new RuleFirstOccrnc() );
        rulesA.add( new RuleOccrncCount() );
    }

    // ******************************************* 
    public static void prioritize( final String aUserInput ){

        rulesA.apply(aUserInput); //ERROR
       // The method apply(String) is undefined
       // for the type ArrayList<ClassificationRule>
        }
} 
package tweetClassification;

public class ClassificationRule {

     // *******************************************
     public void apply (final String aUserInput) {  

        apply( aUserInput );
        }
}
  • 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-01T17:07:54+00:00Added an answer on June 1, 2026 at 5:07 pm

    Right, because you’re calling the apply method on the array list object, not the contents of the array list.

    Change it to something like

    rulesA.get(0).apply()
    

    Or, if you want to call it on every element, you need to iterate through the list.

    for (ClassificationRule rule:rulesA){
      rule.apply(aUserInput);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.