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
Abhishek Sharma 527Abhishek Sharma 527 

getting error in method definition apex

Hello there, I'm doing program in which based on choice account/contact or lead has to be created.
while defining parameterized method I'm getting error as Integer (datatype) does not exist
//code

public class CIS_void_nonVoid_Pts {

    public string choice {get;set;}
    public string Acct {get;set;}
    public string con {get;set;}
    public string lead {get;set;}
    
    
    contact cn = new Contact();
        Account ac = new Account();
        lead ll = new lead();
    public void choiceMethod(){
        
        
        if(choice=='Acct'){
           AcctCreate(String X, Integer Y);
        }
       else if(choice=='con'){
            conCreate();
        }
        else if(choice =='lead'){
            leadcreate();
        }
    }
    
    void AcctCreate(String A, integer B){
        
        ac.name = A;
        ac.Phone = ''+B;
        insert ac;
    }
    
    void conCreate(){
        
        cn.lastname = ac.name +' '+'contact' ;
        insert cn;
        
    }
        void leadCreate(){
            lead ll = new lead();
            ll.lastname = cn.LastName;
            ll.Company = ac.name;
            ll.Status = 'open - not contacted';
            insert ll;
        }
    }

can anyone please help !!
AnkaiahAnkaiah (Salesforce Developers) 
Hi Abhishek,

Can you explain more about your requirement.? What are you trying to achieve here?

Thanks!!
 
Jana ToddddJana Todddd
Apex is a powerful tool for developing custom applications on the Salesforce Platform. However, like any other programming language, it can sometimes present challenges in the form of errors. One such error that many Apex developers encounter is an issue with method definition Apex. This error occurs when the syntax of a method definition is incorrect, or when Salesforce does not recognize the coding language being used.

The method definition Apex error can be especially frustrating because it’s not always easy to identify what’s causing the problem in your code. It could be something as simple as missing brackets or quotation marks – or something more complex like incorrect variable names or data types being used. Luckily, there are several approaches you can take to troubleshoot and resolve this issue.
https://jackpotworth.com/
Abhishek Sharma 527Abhishek Sharma 527
Hi Ankaiah, I'm writing this practice program that'd be linked with vf page and if account is selected in vf page then account should be created, similarly contact and lead, but in apex program i'm getting error here's vf page code for this - please check