function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HAZLITT VASUDEVANHAZLITT VASUDEVAN 

How to display list of account object till a limit of 30 in apex code?

Best Answer chosen by HAZLITT VASUDEVAN
CharuDuttCharuDutt
Hii Hazlitt 
Try Below Code
public class lstAcc {
    public Static list<Account> listAccount(){
        list<Account> lstAcc = [Select id,Name From Account limit 30];
for(integer i=0;i<lstAcc.Size();i++){
    system.debug(lstAcc[i]);
        }
        return lstAcc;
    }
}
Please Mark It As Best Answer If I It Helps
Thank You!

 

All Answers

CharuDuttCharuDutt
Hii Hazlitt 
Try Below Code
public class lstAcc {
    public Static list<Account> listAccount(){
        list<Account> lstAcc = [Select id,Name From Account limit 30];
for(integer i=0;i<lstAcc.Size();i++){
    system.debug(lstAcc[i]);
        }
        return lstAcc;
    }
}
Please Mark It As Best Answer If I It Helps
Thank You!

 
This was selected as the best answer
Suraj Tripathi 47Suraj Tripathi 47
Hi,

You can take reference from the below code:-
public class AccountList {
    public Static list<Account> dispAccList(){
        list<Account> accList = [Select id,Name From Account limit 30];
		system.debug('Size-- '+accList .size());
        for(Account acc: accList ){
    system.debug(acc);
        }
        return accList ;
    }
}

Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi

 
HAZLITT VASUDEVANHAZLITT VASUDEVAN
Thank you so much for responding. It helped me.
@CharuDutt @Suraj Tripathi 47