r/learnjava • u/[deleted] • Oct 10 '16
I'm taking AP Computer Science, and LOVE Java, LOVE how you can create programs with just numbers + letters, but I'm TERRIBLE at answering problems in labs that we do, any sites/books that would help?
I basically am struggling with putting the code that I learned, the pure basic textbook definition onto eclipse and make it work. We aren't even that far, only to the point where we've learned about operators, for and while loops, yet I can't answer the problems or succesfully modify the code to answer the question in labs we do in class.
For all the experienced Java programmers, how did you learn, our textbook is seriously bland and gives bad examples on how certain blocks of code work. Any good sites or books you might recommend me? I know that practice will help, but its more of me not being able to successfully learn the basics. Applying what I've learned is also a struggle.
2
u/desrtfx Oct 10 '16
There are two things you need to differentiate:
Java - the programming language (syntax and grammar) - that part is easy to learn
Programming - transforming a task into something the computer understands - that's the actual, difficult part.
I fully understand the problems that a beginner faces when given a task. Getting over the initial hump to convert a task into a program is difficult. There is no discussion about that.
Programming requires a different way of thinking (that we actually constantly do, but on a subconscious level. Breathing, walking, eating, etc. are all algorithms that we have learned and that we don't need to think about.) What a new programmer needs to learn is to bring the ability to think in algorithms into the conscious mind.
A little trick can help here (from the /r/learnprogramming wiki): How can I improve my skill to convert tasks/problems into programs (Algorithmic thinking)? (I know that the advice sounds somewhat stupid, but it really helps.)
A common mistake that a beginner often makes is to immediately start programming after having been given a task.
When given a new task, spend some time to thoroughly analyse it, to break it down into individual parts (set-up, input, processing, output), sketch some algorithms in plain language or in drawings.
The better you analyse and prepare, the easier it will get to write the actual program.
In addition to the above, I would suggest looking at other sources than your textbook. Here, I would recommend:
Both are free and excellent.
2
Oct 18 '16
Keep at it and eventually it will click. But to help you get there, ask yourself "what is the problem I am truing to solve." I had a little programming background before going to school, and noticed this was the big issue. Another thing I do is, if I can't get something, I take a break, come back and go through the problem again.
1
u/cjthomp Oct 10 '16
Which textbook are you using? Because I'm betting that it's not exceptionally bland nor are the examples especially bad. "Programming" might not be what you expect it to be...
1
u/8igg7e5 Oct 10 '16
I have seen some terribly bad books and I've seen some good books that just don't suit being 'first steps in programming' material.
Add to that the number of times I've seen books printing examples that don't actually work or making reference to tools and libraries that no longer exist.
Personally, I'd suggest IntelliJ Community over Eclipse but that's not going to solve your problems so if you can at least do the following in Eclipse then stick with what you know for now...
Create a project
Create a new Class
Compile a simple HelloWorld and run it
Is there any example or concept in particular you've been stuck on - it would give us something to discuss and get a feel for where you're at with programming in Java.
I started programming a while back so I'm afraid the references and tools I used then are not at all relevant now :)
1
u/desrtfx Oct 10 '16
I started programming a while back so I'm afraid the references and tools I used then are not at all relevant now :)
Since programming is mainly conceptual, resources don't usually go obsolete. They may become aged because of newer software versions, but the fundamental concepts stay the same.
2
u/8igg7e5 Oct 10 '16
Languages change, not only going in and out of style but also evolving.
Even without the languages evolving, the state-of-the-art in terms of application design and structure change over time too as we learn lessons on what works and what does not from bleeding-edge ideas.
My first languages were GW BASIC, Pascal and C. Only C has really endured. I've covered many since.
Even if I discount the materials covering dead languages (I'm not quite dead yet! I don't want to go on the cart) the others are of a style or version of libraries that don't make for good initial learning material. There are some old data-structure books that are still of good value but on whole material in the CS space does indeed age.
Consider the momentous shift toward immutable state and functional styles of composition over Object decomposition and messaging between objects with mutable state. While the languages involved are the same, the standard libraries are slowly shifting to suit these newer models, language features are emerging and platforms and frameworks are optimising for these approaches.
3
u/AngelOfLight Oct 10 '16
Try CodingBat. They have exercises that range from easy to difficult. r/dailyprogrammer is also a useful resource. If you have specific questions, just ask them here.