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
Sammy7Sammy7 

Whats wrong with this code?

I can excute this fine in excute anonymous, but when I put it in the class, I get "Unexpected token: '='" at LINE 5
 
public class testProduct {
    
    public Product2 shipping {get;set;} 
    
    shipping = [SELECT id, name, productcode from PRODUCT2 where productcode='shipping' limit 1];

 
Best Answer chosen by Sammy7
Sammy7Sammy7
Contructor is required. nvm.