OBJECT ORIENTED PROGRAMMING (JAVA)
A. Differences in Procedural Programming and Object Oriented Programming.
The computer program consists of code and data. Program code is a logical process (Eg function) and the data is in the form of variables and constants. In the traditional model or procedural (process-oriented model) all data and code merged into one part in a program. In the programming model object oriented (object-oriented model), components of the program conceptually be broken down into separate parts called objects. Each object has data (properties, variables and constants in the form) and methods (behavior or the ability to do something, be a function). Object definition is a entity that has the data and method. Human examples (objects) have data (Name, sex, weight, height) and method (how to speak, the way walk, how to be angry). In the programming world objects are abstracted as a class (Class). Or in other words, the class is an abstract form of the object. Concrete manifestation instance of a class called. Examples of human beings, then the instance it is Budi, Siti, etc.. Cat class, then it is someone's instansce meow, the sweet, etc..
Advantages of object-oriented pemrogramana are:
o Object-reusable objects (reusable) for programs other.
o The program is more structured and easier to develop.
o Characteristically natural or natural, because the behavior and properties in program will be tailored to the real objects that exist in nature about.
o Object-reusable objects (reusable) for programs other.
o The program is more structured and easier to develop.
o Characteristically natural or natural, because the behavior and properties in program will be tailored to the real objects that exist in nature about.
2. Software needed
To create a java program, the minimum required is:
a. Java 2 SDK, Standard Edition (J2SE). This software downloaded from the bias
http://www//javasun.com/products/. or before the SDK there is JDK (Java
Development Kit)
b. Text editor. Useful to write program code that will
made. Eg notepad. To simplify writing of code
bias is used IDE (Integrated Development Environtment), eg
NetBeans, JCreator
3. Setting the CLASSPATH
CLASSPATH is a system variable that is used to
says the program is written in Java where the location of classes of
to be used. Then we can compile and execute
program that we make of our working directory.
Examples of the working directory in D: \ DATA then typed in the path setting
in the command prompt is set CLASSPATH =. : D: \ DATA
Or if you want to allow the compilation and program execution can
performed from any directory and is permanent, it can be typed
The following command into the AUTOEXEC.BAT file
set PATH = C: \ java \ jdk1.6.0 \ bin;% PATH%
To check whether PATH setting is successful, then type the command
javac or java in any directory.
If implemented in Windows, how to set his path clash is as
the following:
To create a java program, the minimum required is:
a. Java 2 SDK, Standard Edition (J2SE). This software downloaded from the bias
http://www//javasun.com/products/. or before the SDK there is JDK (Java
Development Kit)
b. Text editor. Useful to write program code that will
made. Eg notepad. To simplify writing of code
bias is used IDE (Integrated Development Environtment), eg
NetBeans, JCreator
3. Setting the CLASSPATH
CLASSPATH is a system variable that is used to
says the program is written in Java where the location of classes of
to be used. Then we can compile and execute
program that we make of our working directory.
Examples of the working directory in D: \ DATA then typed in the path setting
in the command prompt is set CLASSPATH =. : D: \ DATA
Or if you want to allow the compilation and program execution can
performed from any directory and is permanent, it can be typed
The following command into the AUTOEXEC.BAT file
set PATH = C: \ java \ jdk1.6.0 \ bin;% PATH%
To check whether PATH setting is successful, then type the command
javac or java in any directory.
If implemented in Windows, how to set his path clash is as
the following:
Step 1.
Turn on the system of control panel, or from Windows Explorer right-click My
Computer à Properties à Advanced.
So that the image will appear as below.
Turn on the system of control panel, or from Windows Explorer right-click My
Computer à Properties à Advanced.
So that the image will appear as below.
Step 2.
Then click Environment Variables that appear as below.
Click on New.
Then click Environment Variables that appear as below.
Click on New.
Step 3.
Fill in the textbox in New user variables, as shown below.
Then click OK.
Step 4.
Fill in the textbox in the New System Variable
Then click OK.
Fill in the textbox in the New System Variable
Then click OK.
Step 5.
Check the classpath setting, by the way go to the DOS Prompt, then type
java or javac in any directory.
If you have any view as above, then setting the classpath succeeded.
4. Creating a Program
The steps to create a program are:
1) Enable Text editor (eg Notepad)
2) Type the program listings
3) Save the file with file name berekstension. Java
4. Creating a Program
The steps to create a program are:
1) Enable Text editor (eg Notepad)
2) Type the program listings
3) Save the file with file name berekstension. Java
Program 1-1
/ * This is my first Java program * /
public class {Programku
public static void main (string [] args) {
System.out.println ("Hello World ....");
System.out.println ("I'm learning java language ...");
}
}
/ * This is my first Java program * /
public class {Programku
public static void main (string [] args) {
System.out.println ("Hello World ....");
System.out.println ("I'm learning java language ...");
}
}
Then save the file by adding quotation marks in the file name. In the case of file name must match the name of the class, because the name of the class in the example program is Programku 1-1 above, then the file name also my program followed by a capital letter or not, because Java is case sensitive (influential case sensitive).
5. Analysis Proogram
1-1 In accordance with the above program, there are several parts:
a. Comment line
/ * This is my first Java program * /
Java provides three ways to make a comment such as using
a / * ..... * /, / /, / ** ..... ** /
b. Definition of class
public class {Programku
Line above the word remedy kunsi class defines a new class and
followed by the name of the class. Why??
In all Java programs are classes (class).
{Curly brackets are used to initiate a block in the program, and closed with a}.
c. Method Definitions
public static void main (string [] args) {
Above line will begin method main () is the main method that would
shared by all Java programs (other than applets) and will be executed first
times when the program starts.
Said public key is used to determine the level of access method.
This means that the method can be accessed by external code (outside of class Programku).
Kunsi word static is used because the method main () will be called by
Java interpreter.
A Java program will not compile without the method main ().
d. Displaying Text
System.out.println ("Hello World ...");
System.out.println ("I'm learning java language ...");
The code above is used to display the text "Hello World ..." and
"I am learning java language ...".
e. End of Course Section
Characterized by a close curly brackets}.
6. Do Compiling Programs
The steps to compile the program are:
1) Enable Prompt or MS-DOS command prompt application
2) Turn on the working directory used to store the file. To enable use the command CD (change directory)
3) Make a program compile with javac command followed by the name file.java The results of the command javac will form berekstension file. Class
4) Execute or run the program
source: STMIK AMIKOM YOGYAKARTA
0 komentar
Posting Komentar