Skip to main content
I always come across two ways of assigning results from a SOQL query to a list and I just wondered if there is any difference between the two:

1. List<Account> exampleOne = [SELECT Id, Name FROM Account WHERE Name = 'John'];

2. List<Account> exampleTwo = List<Account>([SELECT Id, Name FROM Account WHERE Name = 'John']);
2 respostas
  1. 31 de mai. de 2018, 19:25
    Line 2 should be List<Account> exampleTwo = new List<Account>([SELECT Id, Name FROM Account WHERE Name = 'John']);

    And, there is no difference between tge 2, use whichever you prefer.
0/9000