Bismillilah. In the Past, my friend once said, “Perhaps you could teach me programming too.” Despite being a Financial Degree student, he had interest to other fields such as business and computers, including programming. To my surprise, he could actually repair laptop where I can’t, even though I was a Diploma in Computer Science student. So in that thought in mind, I want to try it; to teach others programming, starting with Java. Even though there are thousands or million even references in Internets and Books, I still want to try this with some help. I started with a nice book “Java Examples in A Nutshell: A Tutorial Companion to Java in a Nutshell” by David Flanagan. Though it is supposed to be used in conjunction with other book, but it is a practical way of learning through examples.
Java is an object-oriented language, but at basic we won’t be covering this yet. Let’s start writing Java programs.
Preparation of using Java includes downloading the Java Development Kit (JDK). The latest JDK during this time of writing is jdk1.7.0. You will be using command prompt to compile it. But, you may also use user-friendly compiler such as BlueJ.
My Java Tutorial 1: “First program to write is the same for all language.”
This referred to “Hello World” program.
Explanation:
For this program, it is a public (means it can be used by anyone) class named Hello.
All programs will have main() method. You should memorize this line:
Every
standalone Java program you ever write will contain this line.
System.
out.println() method sends a line of output to the screen. It usually in form
of string, denoted by “”.
// is the
use of comments. This is a C++ style of one-line comments, anything between it
and end of line will be ignored by compiler. Comments are important to help
learning about programming, and to look back at the program in the future.
Maybe you can’t see why now because it is just few lines of programs, but when
it comes to thousands of codes, you will appreciate it. =)
No comments:
Post a Comment