Java Programming Tutorial 2 - The Basics Pt. 2
Tutorial Name: Java Programming Tutorial 2 - The Basics Pt. 2
Category: PC Tutorials
Submitted By: Jimbo
Related Forum: PC Building Forum
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. MW-HWID Ban: Change UUID and Serial of AMI BIOS Motherboard(326)
- 02. How To Mod Call of Duty Modern Warfare 2019(1,104)
- 03. 400+ Best Clan Names and Ideas(5,965)
- 04. Valorant Clan Name List - Best Clan Names(2,098)
- 05. Best Fortnite Clan Name Ideas(2,016)
- 06. Installing and Configuring Raspbian on Your Raspberry Pi [20(277)
- 07. How To use system Recovery in Windows 10 PC(453)
- 08. How To Fix Nvidia GeForce Experience Cannot Optimize Games(812)
- 09. Java Programming Tutorial 3 - Variables(1,244)
- 10. Java Programming Tutorial 1 - The Basics(1,548)
- 11. SLADE3 Tutorial #5 - Bookmark(1,018)
- 12. Windows Basics Tutorial #2 - Navigating Windows(1,071)
- 13. Computer Basics Tutorial #11 - Getting to Know the OS(985)
- 14. Computer Basics Tutorial #8 - Understanding Applications(890)
- 15. Apache Ant Tutorial - Introduction(909)