How to Create Your First Program and Develop Your Programming Skills
If you are reading this blog you are likely interested in programming and want to know
how to start on and develop your programming skills over time. Programming takes patience and there are many techniques that you can use to become competent in it. There are many different languages that people can learn and code in and you may develop a preference for one. Every language has a specific purpose and there are times in which one language is superior to another in various situations. For the simplicity of the tutorial, I will be using Java. Java is a high-level language that makes it easier to read because it is similar to English. Also known as a source program, then they must be converted into machine code so that the computer can read it. This can be achieved with interpreters and compilers. Interpreters are tools that read through one statement of the code at a time, translate them, and then immediately execute them. Compilers, on the other hand, convert the source code into a file and execute it.
How to Create Your First Program in Java
To run Java you will need an IDE (Integrated Development Environment and Java Standard Edition Development Kit. An IDE is where all your programs will be developed. Eclipse is a popular IDE that many programmers use and this is what I will be explaining how to setup. The Java Development Kit includes the Java JRE (Java Runtime Environment) and the Java API (Application Program Interface). The Java Runtime Environment is the program that runs the Java programs while the Java API contains the Java library.
How to Install the Java Development Kit
The Java Development Kit can be found on the Oracle website after doing a simple search. After finding it select the appropriate version for your computer.
How to Install Eclipse
After installing the Java SE Development Kit, the next step is to download Eclipse IDE. Download the installer here: https://www.eclipse.org/downloads/packages/
When you open Eclipse, click on Eclipse IDE for Java Developers. This will allow you to access the tools necessary to start your journey as a programmer.
You will eventually be asked to select a workspace where all your project files will be stored. After you are done naming it, click on Launch.
After there should be a button labeled as Restore that you will click.
Next, navigate to File and select on the option to create a new Java project which you will be naming. Then create a package that will be saved in the project folder. Now that you have created a package, it is time to start coding.
Creating a "Hello World!" program
One of the most popular starter programs is one that simply prints a statement such as "Hello World". After a package has been created, it is time to create a class that is also under File. In this program, we will call the class Hello. Now let's create a main method that will execute the program. The main method will be created as follows down below. Indenting in Java is important as it increases readability but in some other programming languages, such as Python, an incorrect indentation may also lead to errors in your code. Notice below how the braces are situated, two for closing off the method inside the class, and two for closing the statement within the method. This is because it is used to signify which block of code a statement belongs to. After creating the main method, we will be making a print statement. The print statement will be read as System.out.println("Hello World!"); and will be entered inside the main method. To run the program, navigate to Run at the top and the console will display the message.
package Hello
public class Hello {
public static void main(String[] args) {
System.out.print("Hello World!");
}
}
Understanding the components of the program
A Java class is like the blueprint for defining the behavior and state of the object. An example of an object would be a person or car. An object is the instance of a class. The main method is basically the entry point of where the program is going to run. The body of the method is empty initially, therefore, nothing will happen if the user doesn't write anything inside. In this case, a print statement is contained within the method. A print statement outputs a string: "Hello World". A string is a sequence of characters and an object in Java. The compiler assigns the value of the String object with the string literal, "Hello World". The program is filled with keywords that are only able to be used in other ways than intended. For example, the word class cannot be used as a variable name. Other keywords include: public, static, void, and main.
Speaking of these keywords, understanding the meaning of each one is paramount to becoming a better programmer. The word public is known as an access modifier and means that the other classes can access it everywhere. The word static is used to define the variable or method of a given class as constant. For example, the program you created has a method that is static and it is associated with the class. The word void is used to specify that a method doesn't return anything. In the case of this program, the method doesn't return any value type but only prints a string and then terminates. You need to also be aware of special characters or there will be errors. In the program, the special characters include, braces, brackets, semicolons, and quotation marks The braces as mentioned before are used to signify a block, brackets represent arrays, semicolons denote the end of a statement, and quotation marks enclose a string.
How to Become a Better Programmer
Now you may be wondering how to continue to advance your programming skills. One of the most obvious methods is to build up your knowledge by reading up on new concepts that can be found in books and the internet and a multitude of other sources. The main idea is to deeply understand the material and how to apply them to programs. There are numerous problems that you can work out in the world that could help you achieve knowledge on the uses of whatever concept you are researching about. To progress, there needs to be a consistent practice. To understand most programs and problems a person must have built up an understanding of one idea that relates to another learned prior. Focus on programming projects that pique your interest and motivate you. This will allow you to not burn out and lose significant enjoyment.
Create a Routine
As a programmer, it is important to develop a routine that you will follow to study topics that will propel you into being able to solve more coding problems. Remember that experience is key to becoming a competent programmer and you must be willing to put in the effort. There may be times where you are stuck on understanding a concept or don't exactly how to get it working in your program. When you are faced with this dilemma it is necessary to slow down and take more time trying to absorb the information and this is where other resources could convenient. There are many examples of similar problems out there on the internet that you can test and learn from. It also may be necessary for you to get help from others who understand the topic and can explain it clearly to you. Not only may you feel confused about a lesson but you'll likely forget some of what you learned and will have to review. Reviewing can help reinforce knowledge on something that you gaps in your comprehension about initially. Applying a pattern for studying will get you very far as a programmer.

Comments
Post a Comment