The best way to learn a programming language is lots and lots of practice. One learns to play a piano well only by years of practice -- same with progamming languages. At first you will have to constantly read reference books, but the more you program the more you remember and the less you will have to read about it. You will NEVER get to the point where you thik "I know everything there is to know about XXX language" because someone always knows ways to use it that you may not have thought possible or thought about. So unless your are genius (Ph.D. level) then give yourself a couple years full-time study to get to know the language well.
I would suggest two things first apart from the ones posted above. One, one must be very familier with how the data 'flows' in the program. A proper understanding of Flow charts, data diagrams, algorithms etc help in achieving this end. Second, learning the language of programming well to achieve the end goal. Point number one is very important in designing what is to be achieved i.e the 'goal' or 'output' and Point number two is important as a means to achieve the said 'goal' or 'output'.
Learn well to meet any challange a programmer has to face and one should not restrict oneself to steriotyped problems to gain wider perspective.
Good answers so far, I have a bit to add though.
In a way learning a programming language is very, very similar to learning a natural spoken language. Say you grew up speaking English (I have) and you want to learn spanish, you need to practice and use it a lot to get it down. But before you start using it you will need to know the basics like how gender works with el and la for example. Then just work your way up until you start memorizing vocabulary maybe, then some common phrases and sentences.
It's really almost the same thing with a programming language. You start learning the basic syntax of the language, then maybe start working with "phrases" or "sentences" such as how to define a variable or something. Then you just use it a lot and practice! Then once you understand the core of the language you can think of something you want to accomplish with it and that will help you advance your skil.