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
Manish Kumar 321Manish Kumar 321 

Hello I am new to apex

I have just started coding in Apex and in the very begining  I have got an error.

Error - Line: 2, Column: 4
Variable does not exist: name
User-added image
Best Answer chosen by Manish Kumar 321
Dayakar.DDayakar.D
Hi Mukesh,
User-added image

* symbol indicates that class is not saved completley, so please try to save your class again.
There is no problem with code.
Please let me know, if it works.

BestRegards,
Dayakar.D

All Answers

Harshit Garg 6Harshit Garg 6
Hi Manish,

Please use this below code

Apex class:
public class Dog {

    public String Name;
    Public void bark(){
        
        System.debug('test');
    }
    
     
}

Anonymous window code:
Dog d1 = new dog();
d1.Name = 'Tiger';
d1.bark();
System.debug('dfgdfgdf'+d1.Name);

I have tested that in my org .it is working for me..Please use below code.Damm sure it will work for you.

User-added image

Ans add anything in this if you want to.

Thanks,
Harshit Garg
Arvind KumarArvind Kumar

HI Kumar,

I have tried at my end. It is working fine. Please try once again, it will work for you.

Thanks,

Arvind kumar

Dayakar.DDayakar.D
Hi Mukesh,
User-added image

* symbol indicates that class is not saved completley, so please try to save your class again.
There is no problem with code.
Please let me know, if it works.

BestRegards,
Dayakar.D
This was selected as the best answer