You need to sign in to do that
Don't have an account?
Sandy singh
Error com/salesforce/api/String.equals
Hi All,
I am getting stranger error once I used equals method,
Code: String selectedProgramName = 'abc'; for(Integer i=0;i<sample.size();i++) { if(sample[i].trim().equals(selectedProgramName)) { blnAddr = true; break; }} Error Message: java.lang.AssertionError: apex.bytecodeinterpreter.InterpreterRuntimeException: Unable to resolve method reference: com/salesforce/api/String.equals(java/lang/String, java/lang/String)
So can any one let me know region for this.
Thanks in advance,
Sandy
Damien_, that produces a different error:
13:37:13.027 (27494000)|EXCEPTION_THROWN|[4]|System.NullPointerException: Attempt to de-reference a null object
13:37:13.027 (27598000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
Good guess, though.
Sandy, what is the datatype of sample? I'm guessing List, but I'd like to know for sure.
All Answers
Hi,
Try the below code in system debug
String selectedProgramName = 'abc';
list<String >sample =new list<string>{'a','b','abc','xyz'};
boolean blnAddr =false;
for(Integer i=0;i<sample.size();i++) {
if(sample[i].trim().equals(selectedProgramName)) {
blnAddr = true;
break;
}}
system.debug(blnAddr );
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Is there any chance that sample[i] == null? I would make sure it's not null first if you are using it like a normal array.
Damien_, that produces a different error:
13:37:13.027 (27494000)|EXCEPTION_THROWN|[4]|System.NullPointerException: Attempt to de-reference a null object
13:37:13.027 (27598000)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
Good guess, though.
Sandy, what is the datatype of sample? I'm guessing List, but I'd like to know for sure.
If it produces that error... my best guess is that at that point sample itself is null.
Wouldn't it fail when testing for the size()?
It would. I guess its just hard to tell what's going on since we don't really see what sample is, but it could be erroring right when we are checking to see if the value is null before doing the functions on it.
Yeah, we need the preceding code for the sample variable. Until then, we just have to sit on our hands.
datatype of sample is list<string> and same code was working fine, but since few days its showing that errors.
If i used "==" oparator in place of equals method its work fine..
Odd, I wonder if that's an issue with they way they implemented the equals() method. Maybe it can't handle certain characters in your data.
There are a couple of interesting comments for the equals() method, but nothing that would explain this.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm