In this java tutorial we're going to download and install the necessary tools to build java applications so open up your browser and search for jdk download jdk is short for Java development kit and it's basically a software development environment for building Java applications it has a compiler it has a bunch of code that we can reuse it has a Java Runtime environment at a bunch of other stuff so over here you can see this page on Oracle com Java se which is short for Java standard edition click on this now over here click on this icon now on this page we can see Java development kit for various platforms like Linux Mac OS and Windows here I'm on a Mac so I'm gonna download this dmg file over here now before we do this first we need to accept the license agreement all right now let's download the dmg let me open this we're gonna say this package let's double click this and here we see this installation wizard it's super easy just click continue and install you have to enter your computer's password and then alright done beautiful so we can move this to trash now the next piece of software we need is a code editor there are so many cool editors for building Java applications the popular ones are NetBeans Eclipse and IntelliJ in this Java course I'm gonna use IntelliJ but if you have a favorite editor feel free to use that to take this course that's perfectly fine so let's search for IntelliJ download all right you can see download IntelliJ IDEA click on this link over here download the community edition which is absolutely free and it's more than enough for this course so download all right now let's drag and drop this onto the Applications folder beautiful alright we've installed all the necessary tools to build Java applications so next we're gonna look at the anatomy of a Java program in this java tutorial we're gonna look at the anatomy of java programs the smallest building block in java programs are functions if function is a block of code that performs a task as a metaphor think of the buttons on the remote control of your TV each button performs a task functions in programming languages are exactly the same for example we can have a function for sending emails to people we can have a function for converting someone's weight in pounds to kilograms we can have a function for validating users input and so on now let's see how we can code a function in Java we start by specifying the return type of that function some functions return a value like a number at day time and so on other functions don't return anything so the return type of this functions is void void is a reserved keyword in Java and that's why I've coded that in blue here now after the return type we have the name of our function so here we should give our function a proper descriptive name like send email this name clearly identifies the purpose of this function okay now after the name we have a pair of parentheses and inside these parentheses we add the parameters for this function we use these parameters to pass values to our function for example our send email function should have parameters like who is the receiver what is the subject of this email what is the content of this email and so on now in this tutorial we're not gonna worry about parameters we'll look at them in the future now after the parentheses we had a pair of curly braces and inside these braces we write the actual Java code now one thing I want you to pay attention to here is that in Java we put the left brace on the same line where we define our function in other programming languages like C sharp it's more conventional to put the left brace on a new line but we don't do that in Java so we put the left brace on the same line where we define our function now every Java program should have at least one function and that function is called main so main is the entry point to our programs whenever we execute a Java program the main function gets called and the code inside this function gets executed okay now these functions don't exist on their own they should always belong to a class so a class is a container for one or more related functions basically we use these classes to organize our code just like how products are organized in a supermarket in a supermarket we have various sections like vegetables fruits cleaning products and so on each section contains related products by the same token a class in java contains related functions now every Java program should have at least one class that contains the main function can you guess the name of that class.
0 Comments