+ Start a Discussion
prasanth puvvada 4prasanth puvvada 4 

simple visual force static variable program example

sir/mam  i am fully consufed about static variable in salesforce.  please somebody explain any simple static variable code like addition, subtraction etc...    please   and please use this example in apexclass + visualforce page.

and please tell me how to assign set,get to this in apex code.     public static integer a=10{set;get;}    this is not taking.  please help. 
In Apex, you can have static methods, variables, and initialization code. Apex classes can’t be static. You can also have instance methods, member variables, and initialization code (which have no modifier), and local variables:

Static methods, variables, or initialization code are associated with a class, and are only allowed in outer classes. When you declare a method or variable as static, it's initialized only once when a class is loaded. Static variables aren't transmitted as part of the view state for a Visualforce page.
Instance methods, member variables, and initialization code are associated with a particular object and have no definition modifier. When you declare instance methods, member variables, or initialization code, an instance of that item is created with every object instantiated from the class.
Local variables are associated with the block of code in which they are declared. All local variables should be initialized before they are used.

For more details please go through these link

For get set, this link is more then enough
Mudasir WaniMudasir Wani
Hi Prasanth,

Abhi has give a good explination of your question.

For your code snipped which you mentioned use the below code.
public static integer a{set;get;}{a=10;}

Hope this helps !!!!!!!!!