• Advertisement
Sign in to follow this  

[java] Learning Java. Any advice?

This topic is 4781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
I was just wondering how it compares to learning something like C++.

Share this post


Link to post
Share on other sites
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. ;)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
MicroCenter has that same book (but for 1.3sdk) for $5. Just about all 1.3 related books are $5 at microcenter.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 course
for(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. ~_^

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
If I make any suggestions for which book to read regarding learning Java, it would have to be "Head First Java" by Sierra and Bates. It's filled with pics and it's not a technical, I'm-about-to-fall-asleep type of writing. Also, as someone else suggested, "Developing Games in Java" is also a good choice as for game programming.

What I like most about Java is the easy-use of making GUI's through Swing. You can make simple programs look really advanced and technical once you have an understanding of Swing. Another part of the language of Java I like is how there aren't pointers (per-se). In Java, references are really pointers behind the scenes, which actually made it easier for me to learn how pointers work in C++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement