The first thing to note is that Java is Object Oriented. Since it is, there is no entrance to the program like there is in C (similar to what you have here). So, the first thing to worry about is the definition of a class opening.
So this:
Code:
int main(int argc, char **argv)
{
// Do stuff here
}
Doesn't exist in java. So instead, we write a class to be our main entrance location. Lets say its a Bank. This is where you're static main call goes (yes, its still called main, but you get to choose which class' main will handle the entry point):
Code:
public class Bank
{
public static void main(String[] args)
{
// Stuff here
}
}
At least one class needs to implement a main method for you're program to execute.
The first thing to learn is the difference between a class member / method and an object member / method. This is identified with the
static keyword. This means that you use it in the context of a class, not as an object:
Code:
public class Account
{
public static double dMaxWithdrawl;
public double dBalance;
}
// Used as:
Account a = new Account();
System.out.println(a.dBalance); // Print 'this' account's balance
System.out.println(Account.dMaxWithdrawl); // Print the Account class' maximum withdrawl amount
Next, scope. Public, private, protected, and I believe its java that includes package. Public - Anything can access, private only this class (or instance) can use this, protected - Only this class and its children can access this.
Next, datatypes, probably the most important part of programming. Indicates the size of the variable in question, integer = 32bits (on 32 bit machine), char = 8 bits, etc. A class creates a new datatype, so the Account datatype is kind of like a struct representing in this case 128bits in size (2 x 64 bits where 64 bits = sizeof(double)). Datatypes are required in java to assign new variables and return types for methods.
Next is object handling, creating you're class to actually represent data in an individual context. This is really the key component to object oriented programming.
IO handling can go anytime between start and end. I would recommend advanced IO for after object handling is covered, with the exception of the System.out commands, and perhaps the Scanner class for input. These are kind of needed even in a static context so you can see what you're doing (especially if you're reluctant to use the debug tools which I find a lot of my students struggle with - this is you're best friend btw).
Collections are next, necessary to handle lists of data. This includes array's even though they are primitive (and as such not a typeof collection).
Lastly is a gui. Well built software will work the same in both a non-graphical and graphical interface, though the graphical version is easier (point and click versus display and choose entry). GUI's should be built in a way that they interact with you're program the same way you're command line interface should. I'm a fan of the bottom - up programming style.
Tutorials from Sun, these are probably the best you'll find on the net, though you may need to search for some clarification:
http://java.sun.com/docs/books/tutorial/
If you're struggling with datatypes and return values (including overloading), you should consider using PHP as you're starting point. The object core is very similar to java, but PHP is loosly cast (meaning we don't care about our datatypes, it assumes its datatype from the context its in), and we also don't care about return or parameter types. This helps aspiring programmers, though I do recommend you don't forget that most languages enforce typecasting of you're variables and to keep it in mind when you're programming (this function will return an 'int' value, even though we can't program it in a way to enforce it).
I hope that helps, keep the sun site bookmarked, you'll be visiting those tutorials far more often than you think.