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
Pavan Kumar 1700Pavan Kumar 1700 

Unexpected Token ";"

public class GetSetDemo 
{
Private Integer AccountBalance;
     public integer getAccountBalance()
   {
       Return AccountBalance;
   }
   
       public Void setAccountBalance(Integer AccountBalance)
       {
       
           this.AccountBalance=new AccountBlance;
       }   
}


If i am going to save this compiler shows the error like Unexpected token ";"
Why this error how can we acheive this.?
Best Answer chosen by Pavan Kumar 1700
Malika Pathak 9Malika Pathak 9

Hi  Pavan Kumar,

Please find a solution.I hope it will help you.

public class GetSetDemo 
{
Private Integer AccountBalance;
     public integer getAccountBalance()
   {
       Return AccountBalance;
   }
   
       public Void setAccountBalance(Integer AccountBalance)
       {
       
           this.AccountBalance= AccountBalance;
       }   
}

All Answers

Li LeeLi Lee
Hi Pavan, 

I think follow codes is wrong:
public Void setAccountBalance(Integer AccountBalance)
       {
       
           this.AccountBalance=new AccountBlance;
       }
Do you want set AccountBalance as input parameter here, if so please try change this method like this: 
public Void setAccountBalance(Integer AccountBalance)
       {
       
           this.AccountBalance= AccountBlance;
       }





 
Pavan Kumar 1700Pavan Kumar 1700
Hi Lee
Greetings of the day
Thanks for the reply if i used the code, it was rising the error like : Varaible doesnot Exist : AccountBalance"
Malika Pathak 9Malika Pathak 9

Hi  Pavan Kumar,

Please find a solution.I hope it will help you.

public class GetSetDemo 
{
Private Integer AccountBalance;
     public integer getAccountBalance()
   {
       Return AccountBalance;
   }
   
       public Void setAccountBalance(Integer AccountBalance)
       {
       
           this.AccountBalance= AccountBalance;
       }   
}
This was selected as the best answer
Pavan Kumar 1700Pavan Kumar 1700
Hello Malika,
Good Evening!
The Code is working Fine, May i know the difference between " this.AccountBalance= AccountBalance;"  and  "this.AccountBalance=new AccountBlance;"
Could anyone eloborate the scenario. Thanks in advance.

Thanks & Regards,
Pavan Kumar.