Tutorials Navigation
Java Programming Tutorial 2 - The Basics Pt. 2
Tutorial Name: Java Programming Tutorial 2 - The Basics Pt. 2
Category: PC Tutorials
Submitted By: Jimbo
Date Added:
Comments: 1
Views: 1,592
Related Forum: PC Building Forum
Share:
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.
Summary
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.
Getting Started
Last tutorial I left you all with an amazing cliffhanger.
public static void main(String[] args)
System.out.println("Hello TTG");
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:
[ Register or Signin to view external links. ]
I definitely suggest writing it out though that way you can memorize it.
System.out.println("Hello TTG");
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
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:
//
or
/* */
Here's an example:
[ Register or Signin to view external links. ]
Important Terms
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.
Keywords
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:
[ Register or Signin to view external links. ]
source: [ Register or Signin to view external links. ]
Camel Case
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 [ Register or Signin to view external links. ]
Conclusion
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.
Questions?
Feel free to PM me here OR message me on the TTG discord.
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,492)
- 02. How to: Matrix Numbers | Batch File(1,903)
- 03. How to Password Protect Files on Windows(857)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,716)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,133)
- 06. How to embed an image on TheTechGame(3,098)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(12,981)
- 08. Host bot lobbies! Full Tutorial!(11,241)
- 09. Unban yourself [Plutonium BO2](14,240)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,385)
- 11. Best Crosshair Settings for Valorant(6,525)
- 12. Othercide The Surgeon Boss Guide(2,539)
- 13. Othercide Remembrances Unlock Guide(4,460)
- 14. Othercide Beginners Tips and Tricks(2,708)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,845)
"Java Programming Tutorial 2 - The Basics Pt. 2" :: Login/Create an Account :: 1 comment