You need to sign in to do that
Don't have an account?
Sales Force FRM
Unable to compile example on set
Hi Folks,
i am using set but i encountered following error , please refer my program:
1 public class SetDemo
2 {
3 Set<Integer> s = new Set<Integer>(); // Define a new set
4 s.add(1); // Add an element to the set
5 System.assert(s.contains(1)); // Assert that the set contains an element
6 s.remove(1); // Remove the element from the set
7 }
the compile error:
Error: Compile Error: unexpected token: 1 at line 4 column 7
i am using set but i encountered following error , please refer my program:
1 public class SetDemo
2 {
3 Set<Integer> s = new Set<Integer>(); // Define a new set
4 s.add(1); // Add an element to the set
5 System.assert(s.contains(1)); // Assert that the set contains an element
6 s.remove(1); // Remove the element from the set
7 }
the compile error:
Error: Compile Error: unexpected token: 1 at line 4 column 7
I get a slightly different error:
Message Edited by TehNrd on 05-21-2008 09:18 AM
Variables can be defined in a class but any type of code must be in a method.
http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=4745
Message Edited by TehNrd on 05-21-2008 11:36 AM