You need to sign in to do that
Don't have an account?
Error on String method
Error: Compile Error: Method does not exist or incorrect signature: [String].isEmpty() at line 14 column 22
public class Signupcontroller{
public String name{get;set;}
public String password{get;set;}
public String email{get;set;}
public String reEnter{get;set;}
public Pagereference signup(){
Integer result = reEnter.compareTo(email);
try {
if(result !=0){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Invalid'));}
else if (name.isBlank()){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Invalid username'));}
else{
Credential__c obj = new Credential__c(Name = name , Password__c = password ,Your_Email__c = email);
insert obj;
}
} catch(DmlException ex){
// ApexPages.addMessages(ex);
// obj.Name.addError('Exception occured');
// ApexPages.addMessage(new Apexpages.Message(ApexPages.Severity.ERROR, 'Exception occured on insert'));
}
return null;
}
}
I am trying to null check on string name? Can any one help me with this
Thanks
Ishan Sharma
isempty and isblank are static methods of String, so you call them differently to instance methods. Instead of:
use:
All Answers
isempty and isblank are static methods of String, so you call them differently to instance methods. Instead of:
use:
Thanks Bob It will be an addon to my concepts.
Hello Ishan,
For checking null try:
if(name == null)
or
if(isBlank(name))