You need to sign in to do that
Don't have an account?
ethan hunt
Unexpected Token Public
Hi,,
Could you please help mw in the below code as it is throwing an 'Error: Compile Error: unexpected token: public at line 8 column 0'
public class test1
{
public integer text1{get;set;}
public integer text2{get;set;}
public integer text3{get;set;}
public integer text4{get;set;}
}
public decimal avg(int text1,int text2,int text3,int text4) ---------------------------------Errror line...
{
int result;
result = ((text1+text1+text1+text1)/4);
return result;
}
Regards
Hi,
Please remove the end curly braces after the variable declaration.You need to declare all the variable and defining method inside one class .So after defining methods and variable you close braces of class.
public class test1
{
public integer text1{get;set;}
public integer text2{get;set;}
public integer text3{get;set;}
public integer text4{get;set;}
public decimal avg(int text1,int text2,int text3,int text4)
{
int result;
result = ((text1+text1+text1+text1)/4);
return result;
}
}
Please give the kudos ( click on start at left),if this post is helpful.
Please remove the curly braces after "public integer text4{get;set;}" here you have close the class. You have to write everything in you class so put the curly braces at the end.
And for your second problem int is not supported in Apex you have to use Integer for taking integer value.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.