best way to learn java

hello, i have been trying to learn java for over 2 years now, but still cant even write a line of code, i have tried different methods, official java tuts, tuts on multiple other sites, books, videos, looking through source code, etc. but STILL i cant seem to just quite get a grasp on the language… its quite frustrating… so im asking, how have you guys learned, any suggestions?

Honestly, if I were to put 2 years into something and saw barely any result, I’d pick another hobby.

Maybe you simply need a teacher, but I’d advice you to look elsewhere for things you both like and easily grasp.

I agree, you have to enjoy coding a lot. Try to make a simple console game. When you get stuck, look up what’s wrong with your code. Don’t just copy paste someone else’s code. You should make the program COMPLETELY from scratch. If you don’t find it fun at all then you will never be able to program. It’s good to have someone to ask simple questions but if you are getting them to do the work for you then you won’t learn. If you don’t get a sense of satisfaction when you get something working this is a good indicator that programming is not for you.

2 years is a little exaggeration, i am really into it though.

i want to program, i did exxagerate a bit in my post, i have created things very very simple, but i eventually get stuck at a point and dont know where to look for answer, programming is definately for me, i have the patience, i lvoe to do it, but i need a way to expand my knowledge of it, because these ways arnt working.

Whenever you get stuck, post on the newbie/debugging section :slight_smile: I guarantee you will get an answer in less than a day (Unless your question is really strange or stupid and then people are still likely to help anyway). Just ask exactly what is wrong, what you don’t understand, etc. Try not to post big wads of code because that really stops most people from trying to help you.

Most people here seem to love helping others, or they feel as they should contribute after asking questions themselves.

ah yes - I know what point you are talking in learning programming you are talking about, I don’t speak from experience but I’ve seen it it many people
its the point where - you can theoretically program
but when you try to do something practical, you fail at problem-solving using what java offers / what you can do in programming
this is kinda like when someone learns riding a bike, and even though he knows how to do it, after a little while, he just keeps falling

I remember a friend of mine, who today is earning his money with programming - he was at this point
and he wanted to do a games and stuff, but couldn’t solve simple problem, like I remember he asked me “I want the ship to able to dock here, and I want a popup message” and I asked “well whats the problem exactly?” and he said “well I don’t even know how to start.”

You dont know what you can do yet and how it’s going to able to shape what you want to do
And I’m pretty sure that this is simply a problem of experience.

I programmed like A LOT of incomplete games and programs when I started. So I’m not sure what to recommend. As I recall Stanford is using the ACM libraries so that the students can easily program some graphical things and get a feel of it - without caring about details so much. Can be done with AWT too I’m sure.
I am still a student right now, and from many many many examples - I can only say: Don’t program console stuff.
It’s less intuitive, its tedious and the results aren’t fun. Fun is the most important aspect of learning. And when doing graphics you really get that sense of accomplishment.
This is kinda why Stanford uses the ACMs, because creating an AWT Frame or whatever - there is already “a lot” of code you just gotta ignore as a beginner, which ACM really simplifies - but in a nutshell, that is what I recommend, because then you just try playing with settings/parameters and adding and removing and eventually you get it.

this is the PERFECT example of what i mean, what do you suggest?

Basically you need a playground to play around with code, objects, graphics and stuff.
Not sure what is suited best - maybe the other guys know something

I can chime in with my take on tutorials or learning different programming paradigms, but I guess the important question is: where do you get stuck? Everyone gets stuck sometimes, and it’s usually just from trying to do something too complex all in one bite, and not really understanding all the pieces of the problem before trying to write a solution. If you could give a more specific example of one or two places you’ve gotten stuck, the rest of us might have some advice or stories that can help break the jam.

basically, everything, i want to write a game, 2d or 3d it doesnt matter, but i have no idea where to start… how to load maps, how to load images, etc…

Loading images is largely a matter of knowing the API for whatever toolkit you’re using. Maps are complex data structures, persisting them to files even more so.

You really need to start with something simple, and most importantly, something specific. Now with games, there’s a big hump to clear and that’s just getting some graphics on the screen moving around and responding to keys and clicks, but once you’re there, you can take small steps toward your ultimate goal.

There are a lot of projects that aren’t at all simple, and you just cannot start with as your first or even second or third project and these include:
* Minecraft
* Any FPS
* Any RTS
* Any MMO (or anything multiplayer at all)

Once you figure out what you want to write, you’ll want to pick an appropriate technology for your goal. Java2D is probably a reasonable thing to start with. For sure you don’t want to be learning something like OpenGL or 3D programming concepts at all while you’re still learning the ropes.

Alternatively, if you’d rather noodle around and have fun with a more organic approach to learning, you could give something like Processing (http://processing.org) a try. Scratch (http://scratch.mit.edu) is another option, though it’s geared more toward kids than anything else.

ah yeah “Processing”, you could try that

I learnt by following youtube videos and tutorials I found online, I have never been a big fan of learning from books but the only one I do recommend is ‘Sams, Teach yourself JAVA in 24 hours, 6th edition’ its £24 from waterstones,

the two youtube channels I recommend looking at for great java video tutorals are ‘My Bring Back’ and ‘TheNewBoston’.

thats the book i actually have haha XD

I highly recommend TheNewBoston, but the best tutorials IMHO are the official Java tutorials.

I learned java from there http://javala.cs.tut.fi/welcomePage.do
There are about 40 programming task but without boilerplate.

At start I hated start from scratch but after time that is not that annoying anymore. Start from Snake clone. That is simple but still learn lot of basic stuff like gameloop, rendering, collision detection etc.

Do it from scratch and don’t hate exception, it makes me learn lot of java’s underneath.

I’ve been learning Java for the past year or so and game programming about the last 3 months. From my experience it’s not knowing what questions you need to ask to get to where you want to be.

6 months ago I was dealing with which layout to use in a Swing application. If back then I thought 6 months later I would be able to understand what a BufferStrategy is let alone what it is for and how to use it I would have laughed!

Online tutorials only went so far for me and in the end I bought a Java game programming book which takes you through a project start to finish. It doesn’t teach you everything but gives an understanding to move forward with.

It’s very daunting at first, but once you get to a certain point the knowledge will start to snowball. That’s my 2c as a newbie myself!

Its a great book, There is alot of stuff I skipped over when I first started leaning. even silly little things like being able to write ints as “1_123_4323_234” to make them easier to read.

You could also try the tutorials at http://env3d.org

Env3D is a 3D engine designed for people who wants to learn Java from ground up. It allows even beginners to easily and quickly create 3D visualization and games that can be deployed as applet/webstart with a push of a button.

There are lots of student games under the showcase section.