| Webtraffic Exchange | Salesforce

Salesforce Apex FAQ

Salesforce Apex resembles Java programming language, but it uses objects to represent primitives and also offers pre-built methods for commonly performed tasks. Here is a list of commonly used primitive object methods, and functions that can be used with Apex programming language.

  1. What is the best way to test if a String is empty? Apex String class has an isBlank() method which returns true if the specified String is white space, empty (''), or null; otherwise, returns false. The string class also has isEmpty(), isNotBlank() and isNotEmpty() methods. Unlike isBlank(), the isEmpty() method returns false if the specified String is white space.
  2. What is the difference between the array and list? In Apex, the array and list are the same with essentially the same behavior with different syntax. Although you may initialize an array with a fixed size, you can always grow dynamically by adding more elements to an array. Also, array syntax doesn't allow multi-dimensional arrays so a list must be used to represent a multi-dimensional array.
  3. 1. Syntax for creating a List and adding an element.
    List mylist = new List();
    mylist.add('One');
    
    2. Syntax for creating an Array and adding an element
    String[] myarray = new String[];
    myarray[0] = 'One';
    
    3. Syntax for creating a multi-dimensional List and adding an element
    List> mlist = new List>();
    List mylist = new List();
    mylist.add('One');
    mlist.add(mylist);
    
Share this Post: Facebook X LinkedIn Email


0 Comments

Comments are moderated to keep the discussion useful and respectful. Spam, automated submissions, and low-value promotional comments are removed.

  • No comments have been published yet.

Leave a Comment

Related Articles