function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RIteshMRIteshM 

Unexpected String Comparison result

i have some code in apex a function basically

 

 public PageReference find(){
    System.debug('Helloji');
     describe.uniqueFields= new Map<String,String>();
   List<String> ss  = xxx1.split(';');
   System.debug('ss is '+ss );
   System.debug('all fields are '+ describe.allFieldsKeySet);
   
   for(String s : ss)
  { 
  
   System.debug('s is'+s);
   describe.uniqueFields.put(s,describe.allFields.get(s).label);
   }
    return null;}

 

in this function i am getting two logs

11:20:53.322 (322688000)|USER_DEBUG|[450]|DEBUG|all fields are (AccountNumber, AccountSource, Active__c, AnnualRevenue, BillingCity, BillingCountry, BillingLatitude, BillingLongitude, BillingPostalCode, BillingState, ...)

 

11:20:53.322 (322278000)|USER_DEBUG|[449]|DEBUG|ss is ([AccountSource])

 

11:20:53.322 (322829000)|USER_DEBUG|[455]|DEBUG|s is[AccountSource]

 i am not getting why its showing 

s =[AccountSource]

it should be like s = AccountSource  .after that i applied s.removeStart('['); s.removeEnd(']');

still getting same value of s

because it is not AccountSource so

describe.allFields.get(s).labelis getting de - referencing null object because describe.allFields.get(s) returning null thats why

here allFields a map <String, CustomClass>()

and allFieldsKeySet is the keyset of allFields .can you please help how to resove this issue and why s is [AccountSource] no AccountSource

 

mbhardwajmbhardwaj
What is the value of xxx1 if you can debug..