Sign in to follow this  
Stevenx514

Best way to learn the basics of Java?

Recommended Posts

Stevenx514    100
I'm a CS major and we're required to take an introductory Java course first semester. I signed up late and the course is full, so I have to attempt to test out next semester if I don't want to be a semester behind. My friend who took the test told me if you could program, you would be fine. I've been reading from my textbook and the java tutorials at Oracle. I copy code into my compiler and try to understand what each line does. I attempt to write my own code, but I usually have to look at examples to get the syntax right. If I continue this for an hour or two each day all semester will I be okay? Any suggestions?

Share this post


Link to post
Share on other sites
Antheus    2409
It's like all the other languages you already know.

You do love programming, which is what made you sign up for CS in the first place, right?

If not, switch to math or physics. Or law.

Honest advice.

Share this post


Link to post
Share on other sites
Stevenx514    100
<div>I've never programmed in any language before. A better question would be "How do people learn to program in general?" My high school didn't offer any programming classes, and believe it or not there are a lot of freshmen CS majors who have never programmed.</div>

Share this post


Link to post
Share on other sites
HNikolas    192
While the way you are learning it can surely work, I personally would concentrate my learning to the right things with a proper teacher. If you have the bucks to give out, order a book from Amazon.

There are [url="http://www.amazon.com/gp/browse/ref=sr_tc_img_2_0?node=3608&ie=UTF8&qid=1315509131&sr=1-2-tc"]many[/url] books that cover the topic. Java for Dummies(432 pages) and Head first Java(688) are really good picks for beginner and easy to follow or if these do not suit you, you could pick something else.
When learning with book and if the book has examples, be sure to complete them. In addition, making up your own problems that apply the concepts you learned is a great way too.

Share this post


Link to post
Share on other sites
Infernal0010    135
Reading your textbook like you are doing is a good start, but it really depends on the textbook. You can burn through java for dummies quite fast and probably pick up the language quickly too. Why not do both.

Find people in the class and get copies of the assignment questions. Do them as well. Then find someone who got a high mark on the assignments and compare your results.

Do more than the assignments and examples. I agree with HNikolas, you really start to learn the concepts when you apply them to your own ideas.

Hopefully with the textbook you are going to learn the same material as people in class. You should see about arranging a deal to potocopy someone's notes for a fee if you want to verify this.

Because you are new to programming, it might not seem easy, but being an introductory class, you can take to heart that they shouldn't be going crazy into high design or all out OOP right off the bat and it will be easy.


"How do people learn to program?"
Ever broken a problem down into smaller parts to solve indivdually and put them together for the final solution? Congratulations, you know how to program. The rest is all syntax, containers and algorithms.

Share this post


Link to post
Share on other sites
Stevenx514    100
Thanks for the replies. I'm going to order a copy of Java for Dummies. It will be a lot easier to lug around than my 600 page spiral-bound textbook. Luckily the professor posts all the notes and assignments online, so I should have my work cut out for me.

Share this post


Link to post
Share on other sites
jbadams    25676
You need to write code to learn how to program -- it doesn't have to be [i]good[/i] code, and mistakes will provide many of your best learning opportunities, but you need to be writing code -- the way you're starting out by pasting things in is a good start, but you'll need to learn to solve problems as well, it isn't enough to figure out what the functions do if you can't put them together to solve a problem.

Don't worry about having to look things up at first, that's perfectly normal, and even experienced programmers still rely on references sometimes. You'll find that as you get more practice and experience you will remember more and more and won't have to look up the simpler stuff.


Do all the practice problems you can get your hand on, and get feedback on your solutions -- find out if there are different ways you could have solved the problem, and what the strengths and weaknesses of the different approaches are. Try changing things and seeing what happens. Cause errors on purpose and learn to look up the error messages -- you'll probably also get familiar with some of the common errors.


Practice, practice, practice. [img]http://public.gamedev.net/public/style_emoticons/default/cool.gif[/img]

Share this post


Link to post
Share on other sites
Stevenx514    100
I just found a site that has weekly problems for my course, such as "Create two chemical element objects. Each element object has the following attributes... Our program must input each of these attributes from console. The program must prompt the user for data and create a new object for that element." I think a combination of reading and solving problems like these daily all semester will be enough preparation.


Share this post


Link to post
Share on other sites
Infernal0010    135
I agree with the practice practice part but considering you have never programmed before, you need to learn some of the standard parts of programming languages and only a book or a teacher or experienced programmer will explain that in any meaningful way.

You cannot program if you do not know how to use variables, branching, looping, console I/O etc. they are simple and they are the basics but you can't really do anything in a program until you know what those things are and how to implement them in whatever language you are working in. Once you've learned these ideas in one language, moving to another it really does just become a case of similar yet newish syntax.

Share this post


Link to post
Share on other sites
jwezorek    2663
Look, no offense, but be a semester behind. Catch up when you're a sophomore or a junior by taking a heavy load or something.

You don't know how to program. The point of introductory programming classes is to teach you how program. It isn't about Java or the syntax of Java -- the language doesn't really matter. The introductory classes are the most important ones.

Share this post


Link to post
Share on other sites
Adam_42    3629
When I was at university, lecture rooms were never full, although the more practical portions of a course might have had a limited number of places due to say each student needing a computer. You might just be able to find out where and when the lectures are and show up to them so you don't miss the whole thing.

Share this post


Link to post
Share on other sites
jesse007    158
[quote name='Stevenx514' timestamp='1315504087' post='4859134']
I'm a CS major and we're required to take an introductory Java course first semester. I signed up late and the course is full, so I have to attempt to test out next semester if I don't want to be a semester behind. My friend who took the test told me if you could program, you would be fine. I've been reading from my textbook and the java tutorials at Oracle. I copy code into my compiler and try to understand what each line does. I attempt to write my own code, but I usually have to look at examples to get the syntax right. If I continue this for an hour or two each day all semester will I be okay? Any suggestions?
[/quote]

When I read the phrase, "the best way to learn," it tells me that you're convinced that there is some kind of "canonical" method for learning a programming language like Java. I'll save you the trouble of searching for one--there isn't such a thing. If you want to be a writer, then you need to write. If you want to be a runner, then you need to run. Similarly, if you want to be a programmer, then you need to program. Program what? Anything. A programmer can't help but program. If just thinking of learning a new programming language doesn't get you all worked up and excited and ready to crank out code all night long, then you may want to rethink your area of study.

Share this post


Link to post
Share on other sites
Stevenx514    100
I have to take a C++ course next semester so I'll learn to program one way or the other. I've only been practicing for about a week, but I feel like I've learned a lot. Simple code examples don't look completely foreign to me anymore. I am interested in programming. It amazes me how people can go from lines of code to three-dimensional video games etc. It's not that I lack determination, I just didn't know where to start. I'm devoting a lot of time to this, and I didn't want to waste my time doing the wrong things.

Share this post


Link to post
Share on other sites
HNikolas    192
If you really are into game programming, then I suggest you to finish the book and get a strong basic knowledge of the language and how it works. There is no need to know the whole language library from the top of the head but you need to be a good google user to find solutions to the many problems you are going to face.

If you want to skip ahead and see how a simple game is made, then I suggest you to google basic java game tutorials, there are many on the WWW, some better then the others.


Some phrases to google:
game loop AND java
basic game tutorial AND java
2d game tutorial AND java



I think that writing simple games to learn a language, especially an OOP one, is another great way of doing it, so I will list few game frameworks.

Some of these frameworks will get months of work off your shoulders:
[url="http://www.13thmonkey.org/~boris/jgame/"]JGame[/url] (great and very easy framework)
[url="http://www.goldenstudios.or.id/products/GTGE/index.php"]GTGE[/url]
[url="http://slick.cokeandcode.com/index.php"]Slick2D[/url]
[url="http://sourceforge.net/projects/spgl/"]Shaven Puppy Game Library[/url]
[url="http://sourceforge.net/projects/basiliskgl/"]Basilisk Game Library[/url]

Share this post


Link to post
Share on other sites
Gamer Gamester    140
You can learn your first programming language without taking classes, but you'll have to be very disciplined with yourself. If you try this, I recommend striving to be [b]thorough[/b] with learning the core syntax. You don't have to study all the standard Java Libraries as thoroughly as as the syntax (but do learn the common, crucial packages and classes -- a good Java book will probably focus on these).



It's impossible to fully digest what your reading and studying without experience, and likewise, it's hard to gain good experience without first studying. What works best is probably an iterative approach: study, then experiment and play, then study again, then experiment, then study again that stuff you studied the first time, play around with what you're learning some more, etc.

Share this post


Link to post
Share on other sites
dave j    681
You could have a look at [url="http://robocode.sourceforge.net/"]Robocode[/url]. It was originally written by someone at IBM as a way to help people learn programming in Java. The idea is you write code to control a tank and test it in battles against other people's tanks - so it makes a good introduction to writing games as well.

Share this post


Link to post
Share on other sites
Stevenx514    100
I've looked at a tutorial on how to make pong in Java. I copied the code into my compiler and was amazed. Dave, I think you're right. I'm reading lecture notes and the assigned sections of the textbook daily, along with the example exercises. I also have a friend who's been programming for years who is helping me understand some of the concepts. Robocode seems like it will be fun once I get the hang of it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this