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
renu anamalla 9renu anamalla 9 

Null pointer exception n view state and view state error

Please explain to reduce the view state n how solve the nullpointer give me one example
Anupama SamantroyAnupama Samantroy
Hi Renu,

1. To know about View state nothing better than the salesforce documentation. Link
2. Null pointer exception occurs when you are trying to use any object without initialization. For eg. 
Account a;

If(a.Name =='Test') //this will give a null pointer exception. 

Account a = new account();
//now you can access the fields of Account

Garima SGarima S
1. Null pointer exception is caused by a line of code that is trying to use an object that has not been instantiated, or an object's attribute that has not been initialized.
2. View State :Salesforce allows Visualforce pages to have a maximum view state size of 135KB. A smaller view state size generally means quicker load times. In order to avoid this error, minimize your pages' view state.
Here is good explaination to handle view state :

This will be helpful to resolve your problem.