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
TUSHAR KHORGADETUSHAR KHORGADE 

Create a map populate it with two records Odd and Even. Run a loop from 1-50, if you find a even number increase the count for even named record in map or else increase count of odd named record. Odd and even are keys, counts are values.

want apex class code for above program:
Create a map populate it with two records Odd and Even. Run a loop from 1-50, if you find a even number increase the count for even named record in map or else increase count of odd named record. Odd and even are keys, counts are values.
PriyaPriya (Salesforce Developers) 

Hey Tushar

The developer community recommends providing any attempts/code you've started, any errors you're getting, or where exactly you're struggling in achieving this while posting a question.


Thanks!

Salesforce
CharuDuttCharuDutt
Hii Tushar
Try Below Code
public class evenodd {
    public static void unitTest(){
            list<Account> lstAcc = [Select Id,Name From Account limit 50];
        map<integer,string>mapAcc = new map<integer,string>();
            for(integer i=0;i<lstAcc.size();i++){
                if(math.mod(i, 2) == 0){
                    mapAcc.put(i,lstAcc[i].Name);
                   
                }else{
                    mapAcc.put(i,lstAcc[i].Name);
                }
            }
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!