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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:47:39+00:00 2026-06-01T16:47:39+00:00

I’m just starting on Java and I need some help. I know I cannot

  • 0

I’m just starting on Java and I need some help. I know I cannot make a non-static reference on a static method but I need help trying to work around it. I was reading you can access non-static member variables, by creating an instance of the object but I’m not sure exactly how to do it. Here is some on the code. Any help or directions would be reallya appreciated.

package tweetClassification;        

public class PriorityRules {    

    public static void prioritize( final String userInput ){

            ClassificationRule.apply( aUserInput ); //ERROR
                            // Cannot make a static reference to 
                            // the non-static method apply(String)
                            // from the type ClassificationRule
        }
} 

*----------------------------------------------------------------
package tweetClassification;

public class ClassificationRule {

        public void apply (final String aUserInput) {   

            apply( aUserInput );
        }
    }

*----------------------------------------------------------------
package tweetClassification;

import java.util.ArrayList;

public class RuleFirstOccrnc extends ClassificationRule {

    public void apply ( final String aUserInput ){

        for( TweetCat t: TwtClassif.tCat )
            applyFirstOccurrenceRuleTo( t, aUserInput );
    }

*----------------------------------------------------------------
package tweetClassification;

public class RuleOccrncCount extends ClassificationRule {

    public void apply ( final String aUserInput ){

        for( TweetCat t: TwtClassif.tCat )
            applyOccurrenceCountRuleTo( t, 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-01T16:47:40+00:00Added an answer on June 1, 2026 at 4:47 pm

    You can’t refer to non-static variables from a static method because that static method is attached to the class, as opposed to any particular instance. From its point of view, those non-static variables don’t even exist. However, your question is misleading because nowhere in your code do you show any non-static variable members anyway. It would seem your question is more along the lines of how to instantiate an appropriate classification rule and apply it to the static method argument. There are a number of ways to do this, the simplest would be to simply instantiate an instance of a rule:

    ClassificationRule rule = new RuleFirstOccrnc();
    rule.apply(userInput);
    

    But given that you have multiple sub-classes of classification rule, you probably need a more sophisticated method of instantiating them. A factory could be useful here, or you can use some more advanced object creation patterns like Injection.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I have a French site that I want to parse, but am running into

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.