Tuesday, March 8, 2016

Part 3 making Java Program Finally!

                                     THE FIRST PROGRAM YOU NEED TO BUILD
This is Part 3 and the last post we build on for a Java Program before we get into programming based on the simple Hello World. I will break this simple program into a million pieces because when you first see something like this it looks like gibberish and it looks alien like but once I break it down my goal is for you to see the fog clear and get used to seeing this and more in the future. My one tip if you can understand this, you will be able to understand the next steps. The hardest part is looking at each lijne and figuring out what each line means. Once you got that your golden. :-)

Now I know this looks hard and difficult but lets break this down line by line:
each line has a number this is not part of the program it is more for reference to know where your putting down the code, DONT PUT IN YOUR OWN NUMBERS!!!

LINE 1= is called a class each program must have at least 1 CLASS. A class is like a bigger picture for example a human is a class of species, and jayson is a subclass of that. Human is the generalized one and Jayson is the subclass. We will get into more detail in a bit about this. CLASS ALWAYS STARTS WITH AN UPPERCASE!!!

LINE 2: Called the MAIN METHOD: In each class in order to run it has to have a method in order to go, so that is called the main method. ALL JAVA PROGRAMS START WITH {PUBLIC STATIC VOID MAIN(STRING[] ARGS)!!
A METHOD  is a block of statements of code. In this example the main method being used is System.out.println("Welcome to java!"). THIS JUST SHOWS THAT THE INSTRUCTIONS GIVEN TO THE COMPUTER ARE RUN AND PRINT THE LINE WELCOME TO JAVA! thats it!!

This may seem hard at first even when I started writing this code, getting used to remembering the public static void main and the [] was the hardest for me, but with practice will help you make it become natural and flow without slowing you down.

LINE 3: its known as a java comment in which the programmer communicates with the user reading it to show or tell them what is going on in the program.
There are 2 types with slashes: IN LINE COMMENT: // OR /*.....*/ BLOCK COMMENT.
in the code above the comment just tells the person reading it: This is the display message that says welcome to java on the display screen. COMMENTS ARE IGNORED BY COMPILER!!!

LINE 4: is a print line in which the system will print out the line Welcome to Java! using this line:
SYSTEM.OUT.PRINTLN(" WELCOME TO JAVA!")
This just tells computer to output and print to screen the line in ("").

** EVERY LINE OF CODE NEEDS TO HAVE A ; OR ELSE THE PROGRAM WILL NOT KNOW WHERE TO END! 
** EACH BLOCK OF CODE NEEDS TO HAVE A {} IF CONFUSED LOOK AT CODE ABOVE

            BUILDING, COMPILING AND RUNNING YOUR FIRST PROGRAM

STEP 1:
CLICK ON YOUR BUILDER .
 




                                                         STEP 2:
WRITE AND PRACTICE CODE FROM ABOVE IN EDITOR FOR CODING.!!!!!!


STEP 3:
GET TO YOUR TERMINAL!!!!! NOW...
for me im using MAC, in Windows it should be in tools as terminal.



STEP 4:
<YOU SHOULD SEE THIS, IF YOU DO YOUR NOW CLEARED HOT TO COMPILE THE PROGRAM YOU JUST WROTE>

STEP 5:
COMPILE PROGRAM JUST LIKE I DO. IF IT DOESNT WORK REFER BACK TO PICTURES.


STEP 6: IF NO ERRORS IT MEANS IT COMPILED AND WORKS NOW ALL THAT IS LEFT IS TO RUN IT!!!






CONGRATULATIONS YOU JUST SUCCESSFULLY BUILT,COMPILED AND RAN YOUR FIRST PROGRAM! IF YOU CAN DO THIS THE REST WILL JUST BUILD ON THIS, IF THIS WAS HARD, TAKE SOME TIME TO PRACTICE TILL YOU CAN DO THIS IN YOUR SLEEP IT WILL HELP YOU IN THE LONG RUN TRUST ME!!

Thanks for reading and as always Enjoy!!!


No comments:

Post a Comment

Total Pageviews