Question: Why the output of the following code is always `suck`. How to get `happy` as the output? Why the `happy` branch is unreachable?

```
public class HowToMakeStackoverflowBetter {

    private static final int HUMAN_PATIENCE = 10;
    private List<Member> members = new ArrayList<>();
    private int atmosphere = -10;
    private Random r = new Random();
    public HowToMakeStackoverflowBetter(int size) {
        for (int i = 0; i < size; i++) { members.add(new Member()); }
    }
    public Member pick() { return members.get(r.nextInt(members.size())); }

    public class Member {
        private int patience = HUMAN_PATIENCE;
        private Question question = null;
        public Member() { patience = r.nextInt(patience+1) + atmosphere; }
        public void vote(Question q) {
            if (patience >= 0) {
                voteUp(q);
            } else {
                voteDown(q);
            }
        }
        public void ask() {
            question = new Question();
            for (Member member : members) {
                member.vote(question);
            }
        }
        private void voteUp(Question q) { ++q.vote; }
        private void voteDown(Question q) { --q.vote; }
        public String toString() {
            return (question.vote >= 0)? "Happy!" : "Suck!";
        }
    }

    public class Question { private int vote; }

    public static void main(String[] args) {
        HowToMakeStackoverflowBetter stackoverflow = new HowToMakeStackoverflowBetter(100);
        Member me = stackoverflow.pick();
        me.ask();
        System.out.println(me);
    }
}

```

After a 1000 times loop, it gives us 1000 sucks. I remember 2 or 3 years ago, this was not the case. Something changed.

Answer: 
You forgot to initialize `sentinel`

In code below you are trying to initialize sentinel (which is not yet constructed) with sentinel(same thing). So you have to pass something to constructor which can be used to initialize your member variable `sentinel`

```
*sentinel.last=sentinel;

```

Also no need to call destructor like this. Destructor will be called once your `myList` goes out of scope.

```
myList.~linkedList();  

```
You're trying to de-reference the pointers `last` and `next` of member variable `sentinel` when they are not yet initialized.  

And these de-references `*sentinel.last=sentinel` `*sentinel.next=sentinel` are causing the crash because without assigning the values to pointers you're changing the value pointed by the pointers.

You can do like this 

```
sentinel.last=&sentinel;  
sentinel.next=&sentinel;

```

And as pointed out by other explicit destructor calls aren't need here.