Basically, I didn't really read up about the history of Java, thus the introduction would not be about the history of the Java program. For beginner, I think that it is important to understand that programming language such as Java is a way for you to communicate your idea in a way that the computer can understand. Java is just one of the many programming languages that exist. My choice for Java was because it seems easier to pick up as compared to other language such as C++. Another bias was because I had eclipse installed in my computer, hence, I decided I should pick up Java as my first programming language and learn the rest in the near future. (Or that's what I hope - I'm really busy at work to be honest.)
The advantages for learning a programming language is widespread across the net. You could just type in "Advantages of learning programming" and your good friend Google would show you 17,500,000 result in just 0.46 second. (So you could tell that I just did a search after typing this.) Basically, I wanted to learn a programming language to build applications that help to solve problems - That's my dream. Another inner motivation was I'm really interested in building my own entertaining mobile application. To me, having an idea without realizing it is really torturing. Last, but not least, I also hope for a change in career in the near future so that I can do something that I really enjoy. However, that is harder to achieve because I would need quite an amount to study and get myself a certification as the key to such a position. I wouldn't have a chance otherwise.
With that much being said, let's get started with the basics of Java programming:
The very first thing before you could learn any programming language is to download the right platform for you to build your applications or programs on. There are more than enough free platforms available on the net for beginners to practice and learn their choice of programming language. As I have mentioned above the platform that I used would be eclipse for Java programming.
To download it, you may click on the below link and choose standard package for Java programming:
http://www.eclipse.org/downloads/
[For the sake of beginners: Please note that downloading doesn't mean installing. Once you have downloaded the program using an internet browser, you got to click on the download to install the program before you can use it officially.]
Once you have it installed, you can then proceed to launch your eclipse! Horray! [A point to note: the platform you used may not necessary be eclipse, however, because I am using it so bear with me a little. The codes that are presented can be used in any Java programming platform.]
If you are launching eclipse for the first time, you won't get to the above screen directly. They will ask you to create a workspace for the application somewhere in your computer. You can just name your workspace and choose the directory that you want your workspace to be in (so that you can access your work easily).
After that, we can start creating our first new Java application. Just go to File > New > Java Project.
After selecting the above, this little pop-up screen would appear. You can key in the Project name that you like your Java project to be. It can be anything. However, since I am a boring person, I named it as "Beginner Java Programming". The location would tell you where your file is located at.
Before you can start coding, you will have to create a class to type your code in. Please ignore the other tutorials and files I have in my workspace. The file we have created was "Beginner Java Programming" which is the top folder as you can see. To create a class, right click on the folder, select new and click on "class".
After that you will see a pop up box just like this. You will need to give your class a name, however, please note that the name cannot have spaces. I will named mine as "SimpleJavaProgram".
So you will see something like this of course without the second and third line of code. For this post, we will just stick to the basic as it will get pretty long if I were to continue this. Basically, you can type in the above second and third line of code and click on the "run" button indicated by the arrow eye to run the program. You will then see the line "Hello and Welcome to a simple Java Program" in below in the console. That shows you the what you have command the computer to do for you.
Now, I will explain a little on what the code actually represent. For the first code, "public static void main(String[] args)", it is necessary for most Java program to have. Java will only starts running a program with this specific signature. String[] args represents an array of strings which can be typed into the program on a terminal.
As for the third line, "System.out.println("Hello and Welcome to a simple Java Program!"):" generally means asking the program to print out the line "Hello and Welcome to a simple Java Program!". You can change the line within the brackets into any thing that you want the program to print it out for you. "System.out.println" is a command to ask the program to print the line. The "...." means that the line prints is a string (not integers, float, double or other variables which we will get on to them later. The semi colon, ;, tells the program that this is the end of the first command you typed in. If you forgot to type in the semicolon after the command, you will get an error message in the console telling you that there is something wrong with your code.
In Java, the formatting of the code is important and the command of the codes are all case sensitive. This is means that 'system.out.println' is not the same as 'System.out.println'. Therefore, these are the things that you need to take note of when you're trying out codes from the web. If you did not type exactly, you will be getting error messages and you will need to check the line where you can the error and fix the code before you can run your program successfully.
I guess, this is getting pretty long. I will do up another code the coming week and perhaps we can touch a bit on the mathematical operations that we can do on Java.
Thank you for reading if you have come across here by accident. Until next time...I'm glad I was able to finish up this post by today.
No comments:
Post a Comment