Skip to main content
gamedev.net
🔒 Locked

[java] Learning Java. Any advice?

Started by Moe 19 replies 5.4k views
Original Post
Moe
Moe
Hey all, I will be starting school tomorrow at NAIT (the Northern Alberta Institute of Technology). In one of my courses I will be learning Java, which I really know nothing about. I was just wondering if any of you could tell me anything that might be useful in learning Java. Anyone?
aidan_walsh
aidan_walsh
Listen to the lecturer. Study. Practise.

There really are no secrets to learning it...
www.aidanwalsh(.net)(.info)
Moe
Moe
I was just wondering how it compares to learning something like C++.
corliss
corliss
You do not have to deal too much with memory management as you do in C++. Objects are always passed by reference and primitives are passed by value. It is a little harder to write procedural code in java but definitely still possible. =)

Java is not slow, only the code is. ;)
Raghar
Raghar
Quote:
Original post by Moe
Hey all,

I will be starting school tomorrow at NAIT (the Northern Alberta Institute of Technology). In one of my courses I will be learning Java, which I really know nothing about. I was just wondering if any of you could tell me anything that might be useful in learning Java. Anyone?

It's a programming language.

And don't try to make goo of C# fanboys too much. Show them some dignity and knowledge, if that fails use 155 mm howitzer with HE ammo, or plasma gun.
phaelax
phaelax
If this is your first language, then make sure you do all your assignments. Take each assignment and take it further, expand on it. If you take the concepts you're taught and try to apply them to different ideas that what you've been told, you'll be surprised at how much more you'll start to understand what you're doing. I'd say half the java I know I learned outside my classes, but at the same time I strengthened my knowledge of what was taught.
And ask questions if you're confused. Trust me, you won't be the only one getting confused.
Wicked Wesley
Wicked Wesley
Yes, you should definitly get a book of some sort, preferable one that covers all the basics (Object Orientated Programing, Swing, Applets, Network, etc). If you find a subject hard, you can buy a more specified book. (I found one or two Java Basic books very handy, I still use them as reference for some small things that I tend to forget.)

If you got the basics of Java in your hands and want to write Games, I really really recommand the book "Developing Games in Java" by David Brackeen. It's a really cool book, which covers alot of ground.

Just my opinion ;)
Wesley
Check out my site!www.wickedwesley.com
phaelax
phaelax
MicroCenter has that same book (but for 1.3sdk) for $5. Just about all 1.3 related books are $5 at microcenter.
Cold_Steel
Cold_Steel
If you already know another language (or even if you don't though it will be harder to follow), check out Thinking in Java by Bruce Eckel. It's even available for free download! Of course actually having a book makes it easier to read. This book is how I learned Java in about a month (though I already was experienced in C++, which makes it much easier)
______"Man is born free, and everywhere he is in chains" - J.J. Rousseau
Moe
Moe
Hey, thanks for the replies everyone!

I already use C++, and from what I understand, Java isn't massively different. I think it won't take me too long to get the hang of things.
Quote:
Original Quote by Raghar
And don't try to make goo of C# fanboys too much. Show them some dignity and knowledge, if that fails use 155 mm howitzer with HE ammo, or plasma gun.

That's okay. I get to learn C# as well (in the second semester though)[smile].
TriSwords
TriSwords
I know java and im am moving to C++, which isnt terribly hard. C++ to java should be very easy. C# I think was a good intermediate step to C++. It seemed like Java syntax with C++ functionality more or less.
Moe
Moe
Wow.

After reading through some of these tutorials, I think my brain is beginning to melt. I hope it's just the way they comment things, and not the Java syntax that is so ugly. I guess I just have to keep learning until I understand exactly what they are doing. I mean, I understand the general jist of what they are doing, but it looks like the syntax of some of the stuff can get quite ugly.
Raghar
Raghar
Quote:
I think my brain is beginning to melt

Try this:
import javax.swing.*;public class FirstProgram{     JFrame frame = new JFrame("first program");     JPanel work = new JPanel();     JLabel messageBox = new JLabel("Wow it's working");     FirstProgram(){       frame.setSize(300, 300);       work.add(messageBox);       frame.getContentPane().add(work);       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       frame.setVisible(true);     }     public static void main(String[] args){          FirstProgram first = new FirstProgram();     }}and of coursefor(int something = 0; something < 10; something++){....}for(int something = 5; something < 30; something *= 3){....}this works in Java.


Quote:
That's okay. I get to learn C# as well (in the second semester though)

That's what I disliked on schools, they would teach you a different language sooner than you were able to get grip on the first, result is worse than half of the time used for self study. I hope they would at least teach you in third semester a little assembly. They could do also in fourth semester a little compiler design, or computer architecture design. ~_^
Moe
Moe
We are supposed to be learning a lot about program design and logic in the first semester.

I guess with java I'm just not quite used to the language. I think the years of using C++ have perhaps made me a bit biased. Oh well. Time to suck it up and start learning.
BlackReign
BlackReign
Quote:
Original post by Aldacron
If you want to supplement your classroom work I recommend this book. One of the best beginner-level Java books available, IMO.


I have one of his books for C++, he's a good author.
Interesting Dave
Interesting Dave
All you need is http://java.sun.com/j2se/1.5.0/docs/api/index.html and the know how of browsing it.

As with other languages, learn how to read the compile errors and fuck the whole designing stage off and make it up as you go.
Roger that, lets run like hell!
capn_midnight
capn_midnight
Quote:
Original post by corliss
You do not have to deal too much with memory management as you do in C++. Objects are always passed by reference and primitives are passed by value. It is a little harder to write procedural code in java but definitely still possible. =)

Java is not slow, only the code is. ;)

object pointers are always passed by value and primitives are always passed by value. Objects are never handled, it's always object pointers. nothing is passed by reference, ever.
davenirline
davenirline
Quote:
Original post by capn_midnight
Quote:
Original post by corliss
You do not have to deal too much with memory management as you do in C++. Objects are always passed by reference and primitives are passed by value. It is a little harder to write procedural code in java but definitely still possible. =)

Java is not slow, only the code is. ;)

object pointers are always passed by value and primitives are always passed by value. Objects are never handled, it's always object pointers. nothing is passed by reference, ever.

I just had my SCJP seminar. I believe I'm quite proficient with Java until that seminar made me realize I've known just a little thing about Java. Things aren't passed by reference. It is passed by a copy of the reference. The speaker told us everything is passed by value, but he also explained that it sounds passed by reference because it is a copy of the reference. Technically, he said, it is passed by value.

To explain,

Object anObject = new Object();

public void processObject( Object o )
{
...// do object routine
o = null;
}

public static void main( String args[] )
{
...
processObject( anObject );
...
}

The line 'o = null' is what explains what he was trying to explain. He said, if it were really passed by reference, anObject would become null and the memory space it occupied becomes unpointed by any names (candidate for garbage collection). If your thinking passed by value, it's not the copy of the object that is passed, but a copy of its reference. So the real value could still be accessed through the passed reference (sounds like passed by reference), but when you unset this passed reference (set it to null), it won't bother the real reference pointed to the object. I hope this sounds valuable to you.

I may not be able to answer possible arguments about this. But I'll try.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.