OK, well, I really liked Mystic Ravenous's tutorial on C (me learning it now) and I thought I'd do something very similar with java, cos I'm kinda learning it now and know the basics of it.

Here goes...

This first program will be similar to Mystic's first program, I'll store some variables and then print them onto the screen - then we'll progress from there. (don't worry too much about classes and methods at the moment.)

public class Basic //in java, things always need to be in a class
{//opens class
public static void main(String[] args) //methods reside inside classes
{//opens method
String theString = "Hello"; //declaring and initializing a string (not capital S)
char theChar = 'A'; //declaring and initializing a character
int theInt = 45; //declaring and initializing a integer
double theDouble = 4.3688394; //declaring and initializing a double (there are also floats, but they are similar to doubles)

System.out.println(theString); //prints to screen the data held in 'theString' variable
System.out.println(theChar); //you get the point
System.out.println(theInt);
System.out.println(theDouble);
System.out.println("This just prints anything inside the quotes...3u73...39dhsd...yup");
System.out.println("the integer value is: " + theInt); //use + to seperate your own output and variables
}
}//closes class

ok, here is the code without the comments (note, as with C, everything after the // is ignored by the compiler - comment):

public class Basic
{
public static void main(String[] args)
{
String theString = "Hello";
char theChar = 'A';
int theInt = 45;
double theDouble = 4.3688394;

System.out.println(theString);
System.out.println(theChar);
System.out.println(theInt);
System.out.println(theDouble);
System.out.println("This just prints anything inside the quotes...3u73...39dhsd...yup");
System.out.println("the integer value is: " + theInt);
}
}

Some explanations:
1. 'public static void main(String[] args)' is the MAIN method in java that almost all programs have - except for applets...just remember that line and you'll be right - I don't even really know what all those words in it mean
2. 'System.out' this is a built-in class that comes with java and is used to display things on the screen - use '.println' after it to display data and then move to new line or use '.print' to display without moving to a new line
3. note: all data types begin with lower case except for String - so just keep this in mind.

ok, now I'm sure I probably forgot to explain something, so if I did or you just don't get something, just post a reply and I'll answer it.

I will hopefully return to post another tutorial that teaches you something else...hope this helps someone!! (thanks to Mystic Ravenous who gave me the idea to do this)


Greg