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
chikkuchikku 

System.NullPointerException: Attempt to de-reference a null object in apex


it Causing errors while debugging..there any solutions guys.
 
private static  Application__c app{get; private set;}
       public static void   MyController() {
           
           Id id = ApexPages.currentPage().getParameters().get('id');
                  system.debug('--check--'+id);
           try{
                app = (id == null) ? new Application__c() : 
            [SELECT id,Name FROM Application__c WHERE Id = :id];
                
                }catch(System.QueryException e){
            }}
            public static Application__c getapp() {
             return app; 
   }  
 }

 
Suraj Tripathi 47Suraj Tripathi 47
Hi Chikku,
Can you more elaborate or provide your full code for that problem if Possible because I want to understand where the problem occurs so I try to solve this.

But for now, I provide you a reference link that may help you to fix the issue.
https://www.sfdcpoint.com/salesforce/system-nullpointerexception-attempt-to-de-reference-a-null-object/#:~:text=null%20object%20error-,System.,to%20initialize%20the%20memory%20first.

if you find your answer then mark it as the best answer.

Thanks and Regards,
Suraj Tripathi.