Does anyone have any tips to make learning Java easier? Any advice for Java or programming in general?

I've been taking a class and I'm having a bit of trouble memorizing the syntax for some control statements e.g. while, do-while, while, etc. I'd appreciate any advice really.

Thanks!

P.S. Forgot to mention it's an online class :p.

9 years ago*

Comment has been collapsed.

Well, I personally cannot learn programming out of a textbook. I tried, but it never really clicks until I'm in front of a PC doing it.

If you're at the stage of the class where your professor is just presenting these concepts to you, maybe try and do some more hands on work in your free time. Work through the code yourself and see how the syntax interacts with the data being passed through it, it might help cement these concepts in your mind. I believe NetBeans is a free Java IDE/compiler.

9 years ago
Permalink

Comment has been collapsed.

Thank you for your advice!
I forgot to add that I'm taking an online class and I've already got BlueJay for compiling and writing. Thing is, it's not as clear as I hoped and I just need something to help me remember the syntax on top of typing it over and over again.

9 years ago
Permalink

Comment has been collapsed.

Hmm... typing it over and over again is inevitable though. It's coding afterall. ;-) I think you just need to find something practical to develop that uses that particular syntax, even if it's just something small. The best way of learning is by doing.

9 years ago
Permalink

Comment has been collapsed.

I did actually try Googling something for the do-while control statements. Only things that showed up were long examples that didn't make much sense to me :(

9 years ago
Permalink

Comment has been collapsed.

Something like this?

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

Doesn't seem like a very long example, and it is a good representation of how the while/do-while loops would interact with a integer "count" variable. Take that "WhileDemo" class, copy it into your IDE/compiler and watch what it does. Then build something simple like it from the ground up using it as a reference.

9 years ago
Permalink

Comment has been collapsed.

I was really confused for a moment because I've mainly been using single letter variables. XD

Anyway, I think I'm pretty solid on the while statement as I can think of a practical use for it(its actual state of being practical really) whereas I cannot comprehend the do-while very well. Would you happen to have any examples of the use of the do-while?

9 years ago
Permalink

Comment has been collapsed.

According to that link... "The difference between do-while and while is that do-while evaluates its expression at the bottom of the loop instead of the top. Therefore, the statements within the do block are always executed at least once"

Basically, the do-while operates the same way as while, the only difference is that there's no condition to "enter" the loop. It'll perform whatever operations are in the loop, then decide whether or not the conditions are met to exit it.

To summarize per the examples in that link...

while (count < 11) { [code] }; = The count variable criteria needs to be met in order to enter the loop. Once in the loop, that criteria also becomes the criteria to exit.

do { [code] } while (count < 11); = It will always enter the loop and run the code in it at least once. It will only exit the loop if the count variable meets the criteria.

9 years ago
Permalink

Comment has been collapsed.

Like I said to TheDopefish, I think I have the syntax down but the application is still lost on me as it really does act like the while statement.

9 years ago
Permalink

Comment has been collapsed.

How about something like this?

http://mathbits.com/MathBits/Java/Looping/DoWhile.htm

Where it's necessary to ENTER the do while loop in order to ask the "do you want to continue" question... but will only continue (EXIT the loop) if the user answers correctly. A while loop wouldn't really work here since you would want the loop already initiated before requesting the users input, to repeat the question indefinitely if it's continually answered wrong.

Think of something like a program that requests a username/password. It asks the user for the password, and if they enter it wrong, it asks them again, and again, and again, until they get it right.

9 years ago
Permalink

Comment has been collapsed.

Thank you :). Although TheDopefish gave me a similar example, I'm glad to have another.

9 years ago
Permalink

Comment has been collapsed.

make notes... either in notebook or on pc notepad, word, and so on.

9 years ago
Permalink

Comment has been collapsed.

I do a lot of that except some of the descriptions aren't very descriptive :/.

9 years ago
Permalink

Comment has been collapsed.

do you know any other languages? if no, i would suggest to start with something less oop ;)

9 years ago
Permalink

Comment has been collapsed.

I don't sadly :(. But I'm already a good way into the class to switch. That and I can't really drop it; grace period over XD

9 years ago
Permalink

Comment has been collapsed.

don't need to switch. just try something else on your own.
i started with pascal cause that was first language teached in my school, but c/c++/python/basic, maybe even php could tell you bit more about things you can't understand in java. i would say that it's a strange choice to start with java when you have no prior programming experience

9 years ago
Permalink

Comment has been collapsed.

I've found Visual Basic to be incredibly easy to follow, if you can nab a cheap copy of it (or even Microsoft Office/Access since it uses VBA).

9 years ago
Permalink

Comment has been collapsed.

yep, its an easy start since you can just use an excel sheet as input/output, so you have fast results.

9 years ago
Permalink

Comment has been collapsed.

It was the only choice available XD. Thank you for your suggestions though :)

9 years ago
Permalink

Comment has been collapsed.

C/C++ is much more confusing for a beginner than Java. Java is much simpler to learn. Memory management can cause problems even for someone who knows Java.

9 years ago
Permalink

Comment has been collapsed.

well, every language has its pros and cons.

i suggest ada as first language, since there are many checks at compile time, has strong typing and therefore 'prevents' you from writing sloppy code. (check wiki link for details)

9 years ago
Permalink

Comment has been collapsed.

If you don't have any experience with programming, I suggest you start with Javascript.

Main reason for this suggestion: you can easily run it in your favorite browser, no need to install any fancy IDE.

You will find lots and lots of code examples on the web and if you get stuck you'll probably find a solution on stackoverflow.com

Edit: if it's only about java loops, there are basiclly only 4 different types you need to care about all of them listed here

(a) for(variable declariation;bool condition;variable modification)

(b) for(declaration : expression)

(c) while(bool condition){ ... }

(d) do{ ... } while(bool condition)

personally I'm not a big fan of (d), because I don't like to test conditions after the code has run, but there are scenarios where this is useful

9 years ago
Permalink

Comment has been collapsed.

Do you have a scenario where (d) would work? I've read what Dreakon wrote but I still can't wrap my head around it. I think I've got the syntax down. It's just that it acts so much like the while statement that I can't figure out what it could be used with.

9 years ago
Permalink

Comment has been collapsed.

If you know the code will always run at least one time, you can use this. Otherwise you probably shouldn't or wouldn't use it. And a tiny correction for (d): make sure you put a ; at the end of the condition eg. do{...}while(true);

9 years ago
Permalink

Comment has been collapsed.

here's a small example in Javascript where (d) makes sense:

var password= "123god";
var txt = "";
do {
txt = window.prompt("please enter password");
} while (txt != passwort);
document.write("You are now logged in!");


the user is prompted for the password at least once, and he's stuck in that loop until he enters the correct password.

ofc you could achieve the same with:

var password= "123god";
var txt = "";
while (txt != passwort) {
txt = window.prompt("please enter password");
}
document.write("You are now logged in!");

9 years ago
Permalink

Comment has been collapsed.

Thank you! I feel kind of daft now.

9 years ago
Permalink

Comment has been collapsed.

do {...} while is actually pretty uncommon. Just use while loops where appropriate and if you end up with this:

X
while (condition) {
X
};

where X is a group of statements, the same before and inside the loop, then you can rewrite it as a do loop instead:

do {
X
while (condition);

9 years ago
Permalink

Comment has been collapsed.

this

but thats just details you should not worry about when learning a language.
you may as well just use the first type.

9 years ago
Permalink

Comment has been collapsed.

using collections, fuck everything you learn on C about pointers and dynamic memory managment... the garbage collector is your friend now, and it doesn't like looped lists, so don't

EDIT: oh wait, you are a begginer on this.
well, not sure what you can do to remember the syntax... the words used are pretty descriptive... try to use a refence card while you are coding, get a shit with the basic porpuse and example syntax of each sentence...
other thing you could start doing is using MORE descriptive names for your mehtods and variables, don't use "int a, int b, Double g" is a pain in the ass to follow that code latter, and comment, like a mad man/woman.

9 years ago
Permalink

Comment has been collapsed.

More descriptive names, got it. Thank you for your advice and your profanity!

9 years ago
Permalink

Comment has been collapsed.

well, if you speak german, there is a common book Java ist auch eine Insel

besides that:
find small projects and use the language you learn, using it is the only real way to learn a programming language.

look here for lots of things you can do.

9 years ago
Permalink

Comment has been collapsed.

Looking at Java in another language would probably help...if I knew another language fluently >.< Thank you for the link ☺!

9 years ago
Permalink

Comment has been collapsed.

well...the lituature is secondary..

you just have to use a language to learn it. this is more important for programming languages than for natural ones.

the more programming languages you can, the easier it is to learn another one. all you need it a small project you want to do and the language you want to use.

with some experience you get the basics of a new language in 1-2 days and get quite fluent in 2 weeks or so. really mastering it takes some years.

9 years ago
Permalink

Comment has been collapsed.

I'm reading atm a book about C# but it contains a more info about programming and tips for it with using examples on C# . If you can split your mind you can give it a go. The authors got a Java book on same principle but its only in bulgarian.

9 years ago
Permalink

Comment has been collapsed.

Again with the language barriers >.<. I might give it a shot if I can get some free time. Thanks for the link :)!

9 years ago
Permalink

Comment has been collapsed.

My advice for you is hold on for a short time to study programming logic first. Everyone wants to "get the job done" first, but understanding logic will help you a lot learning not only Java, but almost any programming language. After you understand it well, translating the concepts to language-specific syntax will be much easier. There are some easier languages for beginners too (Pascal for example), at least to understand things well... You don't need to build Facebook as your first project.

9 years ago
Permalink

Comment has been collapsed.

I'll do my best to try and slip that in between my assignments. Thank you for the advice!

9 years ago
Permalink

Comment has been collapsed.

Besides being a horrible language it has some of the worst IDEs in existence. Eclipse and Netbeans are abominations. If this is a free online course then you can always go to a more practical language first and go back to it if you really, really want to make android apps.

9 years ago
Permalink

Comment has been collapsed.

It's an online school course. I am however considering trying another language later on. Do you have any favorites/suggestions?

9 years ago
Permalink

Comment has been collapsed.

step 1) don't listen to this guy.

9 years ago
Permalink

Comment has been collapsed.

Try to make small classes that get something from the keyboard, store the info in the attributes and then print them...when this starts to seem easy, make bigger classes that have use smaller classes as members, and then use collections such as lists and arrays.

PS: altough java is a slow and horrible language and its IDEs are written in it, I suggest you to use NetBeans, it has a good code completion and refactoring.

9 years ago
Permalink

Comment has been collapsed.

I'll be sure to check NetBeans out. Thanks!

9 years ago
Permalink

Comment has been collapsed.

Uploaded a summary for you that I wrote during the time I studied Java in the last year. clicky
Might help you.

9 years ago
Permalink

Comment has been collapsed.

Thank you!

9 years ago
Permalink

Comment has been collapsed.

The same approach when it comes to any kind of learning: figure out how you learn best, then go do it.

I hear one of a few things every time it comes to programming:
It's too hard.
It's easy once you get it (usually from a shit programmer).

The bottom line is, learning the basics of the language is easy. Not being a shit programmer/developer is where the hard part is - this entails knowing the nuances of your language, avoiding bad practice and understanding what the compiler does in order to incorporate nice API/architecture tricks.
Java (mostly) takes memory management out of the equation for you, but you still need to be wary of what your code is doing.

9 years ago
Permalink

Comment has been collapsed.

I dunno, I never really liked Java seemed slow and shit to me. I always felt C# .NET as being fast and simple to use. Then again, C# is a lot like Java in terms of syntax, but it just feels so much more snappy for me.

9 years ago
Permalink

Comment has been collapsed.

I don't know whether there's a difference between C# Mono or .Net, but have a benchmark.

9 years ago
Permalink

Comment has been collapsed.

I agree that Java tends to be a bit slower, but luckily the syntax shared is robust. Java is just as good a starting point than any. It's where I got my start anyway...

9 years ago
Permalink

Comment has been collapsed.

Just continue to do what you're doing, there's nothing THAT strange in the syntax, you'll get used to it.

9 years ago
Permalink

Comment has been collapsed.

I can recommend the "Head First": Java

I never read that book, but if it's as good as Design Patterns, it might help you.

9 years ago
Permalink

Comment has been collapsed.

+1
I love their books.

9 years ago
Permalink

Comment has been collapsed.

Mind if i ask what online course are you taking? I'm interested in learning Java when i'm done with a few other languages, primarily Python and Javascript

9 years ago
Permalink

Comment has been collapsed.

It's a course specific to my school system. Sorry :(

9 years ago
Permalink

Comment has been collapsed.

Well i'm not sure how the online course is made, but it might be easier if you go to classes yourself if possible. Between the student teacher interactivity and the possibility to talk to you fellow classmates about the class, you might find it a bit easier. Also, as others already said, you might want to look at an easier programing language, java is powerful, but it doesn't make it the best starter programming language

9 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 2 years ago.

9 years ago
Permalink

Comment has been collapsed.

Go to codeacademy.com. Idk if they have java yet, but if you learn a simple language then it'll be a lot easier to learn other languages. Also try codingbat to test your skills. After that youtube and practice does wonders.

9 years ago
Permalink

Comment has been collapsed.

Closed 9 years ago by TigerLvr.