Activity Forums Salesforce® Discussions How to skip the first item while iteration through list in salesforce?

  • Tanu

    Member
    October 18, 2016 at 6:27 am

    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);
    }

  • Ajit

    Member
    October 20, 2016 at 12:14 pm

    Hi

    counter i=0;

    for(wraper : listOfWrapper){

    counter++;

    if(counter!=1){

    //do you stuff;

    }

    }

    • This reply was modified 8 years, 2 months ago by  Ajit.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos