Get it off your chest – be the first to comment on this video!
No text or picture Add-ons were added yet. How sad!
No Links were listed yet. Go ahead and share!
Before you can program in Java, you need to download and install the JDK or Java Development Kit from Sun's website. Among other things, the JDK includes the Java compiler, class libraries, and the Java Virtual Machine needed to run Java applications. As an alternative, Sun's Download page also has a link to get NetBeans bundled with JDK. This is the IDE or Integrated Development Environment that I will be using throughout this tutorial. It can also be downloaded from netbeans.org. Another great IDE that you can use is Eclipse or if you don't want to use an IDE at all, any regular text editor works fine. When you have your programming environment set up, we will start off by creating a simple Hello World program. As you can see, I have created an empty file called MyApp.java and open it in the editor.
The first thing to do here is create a public class that has the same name as the physical source file. It is legal to have more than one class per file in Java but only one public class and that name must match to file name. Also, keep in mind that Java is case sensitive. The brackets that follows the class name delimits but belongs to the class and must be included. Next, we will add the main method inside of class. This is the starting point of application and must always have this form. The keywords themselves will be looked at in a later section. The last step in our Hello World program is to output a text by calling the print method.
This method is located inside a built-in system class and then another level down inside 'out' class. The method takes a single argument, the string we want to print and it ends with a semicolon as to all statements in Java. If you are unsure of what a specific class contains or what arguments and method it takes, we can take advantage of code hints in some IDEs such as NetBeans. The window normally shows up anytime you are typing code and have multiple predetermined alternatives, but you can also bring it up manually by pressing Ctrl+Space. It is a very powerful feature that instantly gives you access to all class libraries and their members.
Transcription by:
Scribe4you Transcription Services