I'm learning Java, and I found a great teacher. He explains everything perfectly. I understand it all. My problem, is that after learning a short section, for example "Nested If Statements" or "Many Methods and Instances", I can type it all great, but in 5 mins, after going on to a new section (when I'm comfortable with the last section) I forget the code to type for the last section. Any tips or techniques you guys use to remember code????
If you are just rote typing what the teacher shows, the knowledge will go in one ear and out the other. Take the examples he gives, and change them a bit, play around. If they're just exercises, it won't matter. By making even a simple change, like "I want to display the numbers sorted in reverse instead", or something, it forces you to understand the example instead of just copying it. Then take that after class and try to do more with it, extend it, incorporate it into something else. You'll find that your understanding goes up, and when understanding goes up, you don't have to remember as much.
The best way to learn how to code is to write code. I have a saying "The more code I write, the more right I code." Come up with a small sample application that you think will be helpful for you and code it. Come back to http://www.stackoverflow.com if you have specific questions, and go to codereview.stackoverflow.com if you want others to look at your code and give you feedback.
Also read. A lot. Heres a list that'll get you started: https://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read
Don't stress. What you are talking about is "ephemeral". These things (syntax, language quirks, etc.) will become natural through practice, and are constantly changing.
What is most important is that you learn to program. The most important concepts will last throughout your career and will exercise your problem solving abilities, not your memory. An IDE, Google, StackOverflow and practice can help you through the rest.
It's like clothes in a closet.
Without something to hang them on, they will fall to the floor.
What you need to hang programming concepts on is one or more problems you're trying to solve.
Just typing stuff in, without having a problem you're trying to solve, is like throwing your clothes in the closet and expecting them to hang by themselves.
Depending on your learning style, it may be important for you to understand the motivation behind using certain constructs in your programs. Many programming books are written so that they build these concepts upon each other chapter by chapter. Try skimming ahead by one chapter while you're doing the exercises for the prior one.
This way, you can say, "okay, it makes sense to use an
if statement in this case, but I know that in another scenario, it's more effective to use a
switch statement." That way, the concepts are linked in your mind, and you can always briefly check back for any syntax specifics that crop up (and those will definitely become second nature before long).
kylben's idea of extending yourself by modifying each assignment slightly is also a great way to keep on your toes with things. You can also come up with "capstone" projects for every couple of chapters and challenge yourself to build something with everything you know so far.
I couldn't agree more to what the other people have been saying here, programming is learned by doing. The more coding you do generally the more you learn. Having said that many other things are important to learn how to code right, for example never forget to read by looking at how other people learn, read on on new tools and technolgies and browse daily in Q&A such as programmers.com.
As for actually remembering what you learn, once you finished writing a bit of code then explain to yourself silently what you actually have done or explain to a fellow coder. By doing this I find that I remember much more clearly and it gives me the opportunity to reflect on what I have done. Also try to challenge yourself by coming up to alternate ways to write the code you've just written, better or worse. Play around with the problem you solved and think how you would need to change your code if the problem its intended to solve would change slightly.
Maybe writing software is not for you.
When I was 13, I was writing in AppleBasic and Pascal. Programming made perfect sense to me.
It's the opposite with electrical engineer topics. In one ear and out the other. I never learned much in my EE classes, and I quickly realised I was never good at it.
That's why I'm a software engineer now instead of an electrical engineer.
My advice is that you find yourself a small but concrete project. If you want to practice if statements, implementing some kind of classification quiz could be a good excercise: the program asks the user to choose an animal out of a given list, and then asks questions like "Is it a mammal?", "Is it a bird?", and tries to guess what the user has chosen. One way to implement this is using a lot of nested if-statements.
Then you have to struggle through the project from specifying the program behavior, to coding, testing, debugging. Any time you do not remember the syntax or semantics, you go back to your book, read your notes, try to understand compiler errors. When you are finished and your program is working as expected, I am quite sure that you have learnt if-statements (and some other stuff as well).
This is at least the only method that really works for me when I want to learn a new programming language. For example, I have been trying to learn Haskell for the last two years, but just reading the book and writing small pieces of code is not enough: I keep forgetting stuff. Then I had the possibility to write a small tool (in Haskell) at my company, and I really learnt a lot.
Try to explain what you just learned, it doesn't matter to whom (it can be the famous rubber duck), just be serious and patient, and don't leave out things that are "obvious", but pay attention to the details. You'll find out that you still have gaps, and that you need to go back to things you thought to have understood.