-10

I'm trying to use a method to process a String... But I'm getting

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String kuros.com.ipsiscontroller.stringFilter.setStringParam(java.lang.String)' on a null object reference
        at kuros.com.ipsiscontroller.AddActivity.getParameters(AddActivity.java:147)

stringFilter.class

String setStringParam(String parameter){
        /*String finalParam = "";
        String fillString = "";

            if (parameter.length() < LENGTH_PARAMETERS) {
                int missingChars = LENGTH_PARAMETERS - parameter.length();
                Log.d("STRING_TAG missingChars", String.valueOf(missingChars));
                for (int i = 0; i < missingChars; i++) {
                    //fillString = fillString + "x";
                    fillString += "x";
                }
            }
            finalParam = parameter + fillString;
            Log.d("STRING_TAG", finalParam);*/

        return parameter;
    }

As you can see I commented most on the method just to see I get the same String back... but is not working either. This is line 147.

String test = sf.setStringParam("a");
Josue Mavarez
  • 85
  • 2
  • 8

1 Answers1

-2

That method is not static so you will need an instance of stringFilter to invoke that method.

You are calling an instance method on a null instance of stringFilter

David Pilkington
  • 13,528
  • 3
  • 41
  • 73