Unable to declare it
Hi,
I get this error Error: Compile Error: Illegal modifier on local variable at line 3 column 15 due to public String message; why? |
Hi,
perhaps you could provide some more information. Eg what language, and perhaps even show us the code. Evo2. |
Yes, here are the codes in Java:
1 public class StoreFront { 2 public PageReference shop() { 3 public String message; 4 message = 'You bought: '; 5 for (DisplayMerchandise p: products) { 6 if (p.count > 0) { 7 message += p.merchandise.name + ' (' + p.count + ') '; 8 } 9 } 10 return null; 11 } ... and here is the error Error: Compile Error: Illegal modifier on local variable at line 3 column 15 |
Quote:
The easiest fix would probably be to just remove 'public' from the message declaration (so line 3 would just read "String message;"). Or if you really do intend to have the message string be a public member of the StoreFront class (although in this case it seems unlikely) you could switch lines 2 and 3 (and keep the 'public' modifier). Basically the compiler is saying that the words 'public', 'private', and 'protected' are not allowed once you're inside a method. |
All times are GMT -5. The time now is 01:27 PM. |