ok, im gonna try to make this as simple as i can, but java is easy so you will get it for sure! so you will need Jcreator, its the best compiler i have found for free. you can get it at http://www.jcreator.com/download.htm dl the second one, its what you want. once you have that installed open up Jcreator and go to file/new file/ and name it hey(make sure it is saving it as a java file!) ok, now that you have Jcreator open and hey.java ready to go here is the way you set up almost any program you will ever write in java
Code: Select all
public class hey
{
public static void main(String args[])
{
}
}
public static void main(String args[]) is the way most programs are started, pretty easy so far i hope...
the brackets will need to be set up that way, and you put things between the MIDDLE brackets, unless you are adding a new method such as pause, but i wont explain that, because this is the basics.
congrats, you just learned how to and set up a program in java that does absolutally nothing!!! so... how do you change that? by putting stuff between the middle brackets of cource!
Code: Select all
public class hey
{
public static void main(String args[])
{
System.out.println("hey");
}
}
start out with the same format, you can use hey.java if you want, but if you make a new file make sure its public clas followed by the name of the java file not including .java now in the middle prackets put
Code: Select all
int num = 6
Code: Select all
System.out.println(num);
Code: Select all
public class hey
{
public static void main(String args[])
{
int num = 6;
System.out.println(num);
}
}
Code: Select all
public class hey
{
public static void main(String args[])
{
String name = "The Amazing Stephen";
double decimal = 6.32154;
int num = 6;
System.out.println(name);
System.out.println(decimal);
System.out.println(num);
}
}
The Amazing Stephen
6.32154
6
as you can see int is for numbers with no decimals, double is for numbers with decimals, and String is for words and sentences. that is all the variables we will learn for now, because i dont want it to be too confusing. So last but not least... OPERATIONS WITH VARIABLES!!! im gonna give you the code to a program and i should look familiar for the most part, it will have a few minor discrepancies though, but i will explain them.
Code: Select all
public class hey
{
public static void main(String args[])
{
double abooga = 3.1415926535;
int iAmAwsome = 9;
double decimal = 6.32154;
int num = 6;
double total = 0;
total = abooga * iAmAwsome + decimal - num;
System.out.println(total);
}
}
28.595873881499998
so what is that jibberish about changing total from zero to 28.595873881499998? they are called variables for a reason, they can change!!! and what changed it was...
Code: Select all
total = abooga * iAmAwsome + decimal - num;
well thats all for now unless anyone wants more, have a good day ... and here are the pics of compiling and running as i said at the top