Hello! I have been teaching Java for many years, and I wish I could tell you one magic formula.
Certainly what's very important is to practice writing code, lots of code. Don't fret over whether you write the best code right away--of course you won't. Nobody ever does. Try your best, get it to work, and then critique it. Was your solution efficient? Extensible? Object-oriented? A clever hack?
The other practice that is increasingly important in the world of open source is to read other people's code. There are a lot of tutorials out there. Look at the code. Figure out what they did, and just as importantly, what they didn't do.
Write code. Read code. Think about code. Don't worry about mistakes, and don't wait for the silver bullet. That's really what it's about.
Like my doctor keeps telling me, to lose weight, there really is only one way: eat less and exercise more. Hey,
doc, no fair, what about those miracle diets?
Cheers,
Cay