Some advices:
- Always keep your code well indented so you will understand easily what to do if you get errors
- If you are reading a tutorial or a code example, compile it as it is, modify it, re-compile it to see how your changes affect the result and finally write your own version from scratch to see if you learned it.