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.
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.
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.
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.
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?
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.
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.
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
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.
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
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.
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!");
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);
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
Comment has been collapsed.
9 Comments - Last post 8 minutes ago by Mayanaise
21 Comments - Last post 1 hour ago by Seibitsu
1,765 Comments - Last post 1 hour ago by Seibitsu
3 Comments - Last post 4 hours ago by lostsoul67
540 Comments - Last post 8 hours ago by Ledyba
47,106 Comments - Last post 9 hours ago by kbronct
49 Comments - Last post 9 hours ago by blueflame32
3 Comments - Last post 7 minutes ago by pingu23
27 Comments - Last post 24 minutes ago by xurc
8 Comments - Last post 32 minutes ago by Droj
794 Comments - Last post 1 hour ago by JimLink
95 Comments - Last post 1 hour ago by Xeton99
2 Comments - Last post 1 hour ago by Zarddin
19 Comments - Last post 1 hour ago by Bum8ara5h
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.
Comment has been collapsed.