• #16739
    Salesforce | PRANAV PRANAV #679
    Forcetalks

    How to skip the first item while iteration through list in salesforce?

    Hi All,

    How to skip the first item while iteration through list in salesforce?

    Actually I want to skip the first item from a wrapper class list.

    Thanks

     

    #16740
    Salesforce | Tanu Tanu #388
    Forcetalks

    Hello Pranav,

    You can do this by using the regular loop like this

    int size = myList.size();
    for (int i = 1; i < size; i++) {
    myList.get(i).doSomething();
    }

    for example-

    list<Contact> con = new list<Contact>();
    for(Integer i=0;i<10;i++){
    Contact c = new Contact(lastname=’tt’+i);
    con.add(c);
    }
    insert con;
    for(Integer i=1;i<10;i++){
    System.debug(con.get(i).lastname);
    }

    #16755
    Salesforce | Ajit Ajit #343
    Forcetalks

    Hi

    counter i=0;

    for(wraper : listOfWrapper){

    counter++;

    if(counter!=1){

    //do you stuff;

    }

    }

    • This reply was modified 2 years, 3 months ago by Salesforce | Ajit Ajit.
Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?