Trending Now

Monday, May 6, 2019

Java Tutorial | Java Programming Made Easy | Learn Java



Java Tutorial | Java Programming Made Easy | Learn Java

hello in this Java tutorial we're gonna start by learning how to write our first program to begin with we must declare a class every program in Java must have at
least one class to do so we'll type on

the first line public class and then the name of our class in Java classes names are written in Pascal case that means all words are run together and the first letter of every word is capitalized I'm gonna call my class my first program our class name must match our file name exactly except our file name will have dot Java at the end otherwise the programs not going to build next we have to define for the computer where the class begins and ends we do that with curly brackets

we'll start with an opening curly bracket and close within closing curly bracket inside our class we need methods every program must have at least one main method that tells the computer where to start when we run the class a main method must be written exactly like this public static void main open parenthesis spring with a capital S open close hard brackets Arg s close parenthesis next we need to define where our main method begins and ends

so we do it that with curly brackets again our main method begins after this curly bracket and ends after that curly bracket an important rule with curly brackets is when we open one everything after that is indented one more line when we close one everything after that is indented one less line the next command we're going to learn is the system.out.print line what that'll do is let us output

something to our console down here so we have system with a capital S period o UT that period free are int L n and then we have an open closed parenthesis inside here is the information or the data we want to go to the console in this case we're going to use something called a string literal a string literal is some very specific text or numbers so we're going to open and close parentheses that lets the computer know that there's going to be a string literal inside here and my message is going to be hello world we must end this line with a semicolon certain lines of code must end with a semicolon like system.out.print lines other ones like public static void main or the class name do not end with a

semicolon we have an open and closed bracket to define where the main method or the class begins and ends let's check if we did everything right what we're going to do is we're gonna go to build and compile this might look different if you're using a different IDE but it'll be the exact same concept what this does is text the program for errors and converts it to byte code which the computer can run this didn't give us any errors that means as far as it can tell we didn't make any mistakes now this is ready to be run so I'm going to go to build run and our program ran an output at hello world to our console for our next lesson will be a video that you can click on on the left side on the right hand side will be a link to the entire curriculum. Thanks...

No comments:

Post a Comment