1

I have a custom object called skill_Review and I am creating a list in my controller using:

 List<Skill_Review__c> skillRev  = new List<Skill_Review__c>
    List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ];

I have another list named skillRev of type skill_review_c in my controller. I want to get each field value in result and put it in the skillRev. Basically I would like to clone results list to skillRev. How can I do this? Is there a way to access Skill__c from results in controller like results.Skill_c?

3
  • question is not very clear. but are you looking for this skillRev.addAll(results) ? This will add all values if result into skillRev list
    – Ashwani
    Commented Mar 16, 2016 at 5:43
  • How can I get Skill__c from results list in my controller?
    – SfdcBat
    Commented Mar 16, 2016 at 5:45
  • Can you post some more relevant code to figure out what you are trying to achieve? otherwise, skillRev.addAll(results) is sufficient to add value in skillRev assuming it is a controller variable.
    – Ashwani
    Commented Mar 16, 2016 at 6:03

1 Answer 1

4

If you look into documentation

You can use list.clone()

Example

List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c 
                                    FROM Skill_Review__c 
                                     where Interview__c =:review.id ];
    List<Skill_Review__c> skillRev = results .clone();

Like @Ashwani said you can use addAll() method here

  List<Skill_Review__c> skillRev =new List<Skill_Review__c>();
  skillRev.addAll(skillRev );

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .