Thursday, February 23, 2012

Chapter 02: Beginning Java




 Basically...

There is only one skill required to program. It is Problem Solving ability. If you can solve problems with plain mathematics, then you can learn to write programs very easily. There is a strong link between math and programming.

The ability to solve problems cannot be taught. It comes only by practice. The more you solve, the better you become.

All Programming languages are same.

There are around 400 programming languages in the world. All of them are different in the way they work. There is no one language which is better than the other one. The choice of picking the best language depends on what you want to achieve. Should that give me better Speed? Assembly level programming? Portability? Rich looking UI? Scientific Computation?

The choice of programming language depends on the need of that software that we are going to build.
Here is a big list of all available languages: http://en.wikipedia.org/wiki/List_of_programming_languages

Idly. Pizza. Rice. All are differently made, but they are consumed by us to satiate hunger.

Programs are everywhere.

When you move a mouse, there is a program running inside, that moves the cursor.
When you type a key in your keyboard, there is a program running inside, that prints that character on screen.
When your mobile phone is in your pocket, there is a program running inside, that waits for a call or SMS.
When you turn on your washing machine, there is an intelligent program that washes your clothes.

From an Alarm clock to a satellite launch, there is a program in everything.

Programs are written in Editors

Programs can be written using any text editor. A text editor is a software using which we can enter and save text content. Notepad is a good example. Just like Notepad, we can write a program in any software such as Wordpad, MS Word, Textpad.

Certain software are available in the market which are specifically built for writing programs. Microsoft Visual Studio is a famous editor software written by Microsoft for .NET developers. Other examples of such softwares are Net Beans and Eclipse.

In this tutorial series, we will first write programs in notepad. Later we will move to Eclipse.

Writing your first program:

public class HelloWorld {
  public static void main( String[] args ) {
    System.out.println("Hello world!");
  }
}

After writing a program, we COMPILE it

Idly. Pizza. Rice. All are differently made in different size. For the body to digest it, we have to chew them and then swallow them inside. For the digestive system, everything is converted to energy and minerals such as protein, Vitamin and Fat. At the time of eating, everything is different but inside, they are all one and the same. Compiling a program is akin to chewing food. 

We know there are 400 programming languages. All of them have a different set of syntax but after the program is written, it has to be compiled. Compilation is the process of converting the program written by a human being into a format which computer can understand. This format is often called as machine-readable code, or object code or binary code or machine code.
A compiler is a program that translates human readable source code into computer executable machine code.
There is another thing called Interpreter which does the same as what a compiler do, but does it line by line.

If there is a 100 line program, A compiler will compile all the 100 lines and say at the end, "7 errors found". An Interpreter will run through the program line by line, and will stop the moment an error occurs.

For more information on compilers, read here: http://en.wikipedia.org/wiki/Compiler

Downloading & Installing JDK

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Compiling a Java program

Syntax:
javac [filename.java]
Example:
javac helloworld.java

After compiling a program, we EXECUTE it

After compilation, a system-understandable code is ready. Now the system can run this and start solving the user's needs.
Syntax:
java FileName
Example:
java HelloWorld

6 comments:

  1. Thanks.. Please upload next chapter

    ReplyDelete
  2. very very nice teaching sir, thanka a lot sir. please upload 4th chapter of java

    ReplyDelete
  3. ur teaching is very gud sir...please upload 4th chapter soon..we r eagerly waiting ...

    ReplyDelete
  4. very nice teaching ... pls upload next chapter of java...

    ReplyDelete
  5. pls upload next chapter it very intresting of java

    ReplyDelete

Our Google Group

Our Facebook Group