I heard the same rule that applies for variables doesn't apply when we're talking about data structures. Is this true?

For instance, this, which is perfectly fine

```
public class SynchronizedCounter {
    private int c = 0;

    public synchronized void increment() {
        c++;
    }

    public synchronized void decrement() {
        c--;
    }

    public synchronized int value() {
        return c;
    }
}

```

does not mean that the following will work flawlessly.

```
public class SynchronizedDataStructures {
    private ArrayList<String> c = new ArrayList<String>();

    public synchronized void add1(element) {
        c.add(element);
    }

    public synchronized void clear1() {
        c.clear();
    }

    public synchronized int value() {
        return c;
    }
}

```

Is this true and what can I do to make it work for data structures?