+ Start a Discussion
shaqib ahmadshaqib ahmad 

unable to call class/methods

public class Dog 
{
   private String name;
    private Integer age;
    
    public void setName(String n)
    {
      name=n;  
    }
    public void SetAge(integer j)
    {
        age=j;
    }
    public String getName()
    {
        return name;
    }
    
    public Integer getAge()
    {
        return age;
    }
    public void bark ()
    {
        
        
        System.debug('');
    }
    

}
///
I am using this apex code 
Dog d1=new Dog();
d1.setName=('frido');
d1.setAge=12;
System.debug('the name is '+d1.getName() +'' +d1.getAge());
Best Answer chosen by shaqib ahmad
ANUTEJANUTEJ (Salesforce Developers) 
Hi Shaquib,

Please try using the below code:

public class Dog
{
   private String name;
    private Integer age;
    
    public void setName(String n)
    {
      this.name=n;  
    }
    public void SetAge(integer j)
    {
            this.age=j;
    }
    public String getName()
    {
        return name;
    }
    
    public Integer getAge()
    {
        return age;
    }
    public void bark ()
    {

        System.debug('Bow Bow!!!!');
    }
    

}


---------------------------------------
Dog d1=new Dog();
System.debug(d1);
d1.setName('frido');
d1.setAge(12);
System.debug('the name is '+d1.getName() +'' +d1.getAge());

Hope this helps and please close the thread marking the best answer so as to keep the commmunity clean and so that it is useful for others in future.

Regards,
Anutej

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Shaquib,

Please try using the below code:

public class Dog
{
   private String name;
    private Integer age;
    
    public void setName(String n)
    {
      this.name=n;  
    }
    public void SetAge(integer j)
    {
            this.age=j;
    }
    public String getName()
    {
        return name;
    }
    
    public Integer getAge()
    {
        return age;
    }
    public void bark ()
    {

        System.debug('Bow Bow!!!!');
    }
    

}


---------------------------------------
Dog d1=new Dog();
System.debug(d1);
d1.setName('frido');
d1.setAge(12);
System.debug('the name is '+d1.getName() +'' +d1.getAge());

Hope this helps and please close the thread marking the best answer so as to keep the commmunity clean and so that it is useful for others in future.

Regards,
Anutej
This was selected as the best answer
shaqib ahmadshaqib ahmad
Thanks,
Anutej