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
Andrey BolkonskyAndrey Bolkonsky 

Trying to Understand Properties and Failing at It :(

I am still very new to writing code and am currently studying the Apex Developer guide page by page. I really could use some help undertanding what properties are for. 

The guide gives the following examples but really doesn't do a good job of explaining what the point of using these things is and why you would use one instead of just declaring a variable like Integer i = 5;

Can someone shed some light on what these are helpful for or even share a practical use case for them? I am totally lost.
 
public Integer prop{
        get {return prop;}
        set {prop = value;}
    }
public Integer MyReadOnlyProp { get; }
public Double MyReadWriteProp { get; set; } 
public String MyWriteOnlyProp { set; }