Friday, March 25, 2011

Steps to create a Java program

Steps to create a Java program:
Writing a program with a text editor. Examples tekx editor that can be used include Notepad, vi, emacs, etc.
Storing the results of the program with the extension. java.
Compile the program using the Java Compiler. The result of compilation of bytecode file with the extension. class. This file will then be converted by the Java interpreter into machine language appropriate to the type and platform used.
Ok now we try to write simple programs with language. We could use an editor available, such as Textpad, Notepad, and so forth. In this exercise we use Textpad are lighter and easy to implement.

public class First
{
public static void main (String args [])
{
System.out.println ("My First Program");
}
}

To find out how the output of the program we follow the steps - these steps:

Select Tools, Compile Java or Press Ctrl + 1

Next Command Result will appear, usually if there are no errors it will display the main page of programs and messages Tool completed successfully at the command result or the lower left corner of the program.
Having succeeded in compiling, Select Tools, Run Java Application or press Ctrl +2 and output will appear

The first line is the name of the class that we make. the First. Well in java, the writing is case sensitive meaning uppercase and lowercase letters writing will be different. To penamaannya use the extension. java and must match exactly with the class that we make. So we must ngesavenya "Pertama.java".


Java program will run at least one function that is played, the word void in front of it means that this function will not issue a good value (return value). Open curly brackets means that marked the beginning of the command to be executed and should be closed with a cap of curly brackets. So always use curly braces even number.
System.out.println used to create the output. while the sentence that is between quotation marks is a string constant which will be displayed on the screen (output).

No comments:

Post a Comment

 
THANK YOU FOR VISITING