Java Programming Tutorial 2 - The Basics Pt. 2
Tutorial Name: Java Programming Tutorial 2 - The Basics Pt. 2
Submitted By: Jimbo
Jimbo's Java Class - Tutorial 2: The Basics Pt. 2
Previous Tutorial: Tutorials/id=23699/java-programmi...asics.html
Hello and welcome to my next Java tutorial. I'm professor Jimbo, an IT student at the University of Central Florida experienced in programming especially Java. In this tutorial I will further discuss the basics of Java programming.
In the previous tutorial I discussed the basics of setting up a project and getting your first project up and running. In this tutorial I'll be going more in depth of the basics of Java programming. In the next tutorial we will begin variables.
Last tutorial I left you all with an amazing cliffhanger.
public static void main(String args)
What exactly do these two lines of code mean? What do they do? Let's start with the first one. To make it easier I will break each word up.
public static void main(String args)
Public: The word public in Java is an access specifier that allows the main method to be accessed everywhere. This starts to become useful when you have projects with multiple classes.
Static: Static helps with other instances or objects to be called. Will rarely be used until in later tutorials.
Void: Void will clarify that the main method will not return any value.
Main: This is actually just the name of the method. Technically this can be named almost anything but for the sake of convention I always name it main.
String args: Here we are defining a String array. You will learn more about arrays in the later tutorials. As for args it's just the name of the array. It can be named almost anything but like main we name it args for convention.
If you ever want a shortcut to make this method there is an option to do so when creating the class:
I definitely suggest writing it out though that way you can memorize it.
This line of code is much more simpler than the first one. You start off by accessing the System class. Here is the definition straight from Eclipse.
"Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array."
It is then separated by a "." (which is use to separate both) followed by "out" which stands for output because you're outputting to the console. Println stands for "Print Line". Put them all together and you're telling the system class to output a printable string. As for the (""), you're writing inside the quotations what exactly you want to print. The line of code then ends with a semi-colon (;) which is basically the period of programming. It's ending the statement just like a period ends a statement.
Comments are extremely useful in any programming language and you should definitely get used to using them. They are completely ignored by the compiler so you can write whatever you want. To write a comment you can either do the following:
Here's an example:
Object: "Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behavior such as wagging their tail, barking, eating. An object is an instance of a class."
Class: A class is the template of the program. Kind of like a blueprint but it describes the behavior that the object of its type supports.
Method: A method is a behavior within the java program. It is designed to contain written logic, data manipulation and execute actions.
All three of these will be given examples in later tutorials.
Key words also known as reserved words are words that cannot be used as an identifier (like a variable). Here is a list of keywords to remember:
Camel Casing is the last subject I'd like to discuss in this tutorial. It's a conventional term but almost all programmers use it. You can read more about it
Congratulations! You now know enough basic information about Java programming to begin your journey on becoming a Java master. Make sure to check out the next tutorial as I will start discussing variables and fun little programs you can create using them as well as optional assignments that you can do to earn a gift of gold.
Feel free to PM me here OR message me on the TTG discord.
- 01. Java Programming Tutorial 3 - Variables(429)
- 02. Java Programming Tutorial 1 - The Basics(573)
- 03. A Simple HTML Document(269)
- 04. [HTML] HTML Basics(294)
- 05. C# Allow only 1 instance of a form to be opened(1,912)
- 06. [VB.NET] How to make and save settings(1,417)
- 07. VB.NET] Open Site when Tool opens(618)
- 08. [VB.NET] Opening external programs / Links(692)
- 09. [VB.NET] Message Box(723)
- 10. [ VB.NET ] How to use progress bars(1,188)
- 11. [VB.NET] How to extend your application size(937)
- 12. [VB.NET] How to make flashing text(2,245)
- 13. [VB.NET] How to use a progress bar(1,195)
- 14. [VB.NET] How to Make a Splash Screen(2,023)
- 15. [VB.NET] How to Make a HTML Editor(1,059)