Understanding the Basics of Java Programming
In this article, we discuss about basic Java programming. How to start to write a Java program code, and most important is to understand the basic concepts of object-oriented programming.
There are several tool which makes them into a unity. For example, JCreator, NetBeans, or Visual J ++. With tools, we can write a program, compile and execute with a "tool".
Actually, it is not advisable to use tools in the writing program. With tools, a lot of which is automatic. So, we become spoiled and will not understand the basic concepts of Java programming.
Problems complained mostly students and students when learning basic Java programming is on understanding Object Oriented Programming (OOP). Before discussing more about OOP, will be discussed first "how to start" learning to program with the Java programming language.
To type a program code can be used notepad. Once the program is completed typed, the file is saved with the extension of Java. For compile and the execution of the program, use the command prompt.
public class Hello World
{
public static void main (String args [])
{
System.out.println ("Hello World");
}
}
Example, for a variable length of a square, pp written. For now maybe we can remember. But, one day we can forget what it stands pp. Therefore, it is important to write a comment on a variable line or anything that requires explanation.
To write a short description, beginning with "//". For example, variable length // square. This method is used to write comments written on one line. If the statement is quite long, how to write is by flanking comments with / * and * /. Here is an example of writing.
/ * rectangle is a quadrilateral that has four equal angles is 90 degrees * /
At the time of program execution, the comment will not be displayed. This comment only helps us to understand the commands that exist in the script programs.
Procedural programming languages execute the program sequentially, starting from the first line to the last line of program code. In contrast to object-oriented programming language that has many class or method. The process is not always sequential program execution from the first row to the last row.
Method main is method are executed first. Thus, main method can be considered as method parent. All method or class the other was called here. Example main method is as follows.
public static void main (String args [])
{
System.out.println ("I executed first");
}
Method main this is public. Args parameter (an array) in the form of a string variable. Method This displays the words "I first executed" on the monitor screen.
To make it easier to learn about OOP in a basic understanding of Java programming, example object directed at objects or humans and other living things around us.
Java language is a programming language that is case sensitive. That case sensitive is sensitive to capital or non-capital letters. So, if it is written "Table", will be different from the "table". For the name of the object in the Java language, letters are usually written with a capital letter in the future. In this discussion, we suppose that the table object is written to the "table".
Before describing the properties of the object, first we have to declare of each object. Each different table should be given different names as well.
For example, Mr. Andi had 4 children named Ana, Bona, Cici, and Dodo. Each has a desk. To study table Ana, Bona, Cici, and Dodo each named mba, MBB, mbc, and mbd.
Giving the name of each object in the Java programming called instantiation. Here's how the objects instantiated table.
For another instance of the object table as well as how to write it.
From the few examples given, visible object or objects that have been instant and written with the non-capital letters. Try the instant object naming is not too long. Maximum 3 letters only because instant later the object name will be written over and over again.
For those of you who do coding by using the tool, will not be too bothered. But, for those who write program code using notepad, be quite tiring. However, again I remind you, is not recommended to use tool when you're trying to understand the basic Java programming.
Java programming can be more easily developed if the understanding of the basic concepts of Java programming is quite strong. Therefore, strengthen basic understanding of OOP concepts. Hopefully the correlation between Java programming with objects around us in this article can help you to more easily understand the basic Java programming.
Object Oriented Programming
Object-oriented programming is a programming parts can be correlated with real objects in everyday life. Understanding of object-oriented programming into the foundation when we learn the basics of Java programming.Case Sensitive
Java is an object-oriented programming language that has the properties case sensitive. Case sensitive means that there is a difference between "M misspelled" with "m misspelled". Unlike capital letters and small letters will give a different meaning. For more details, will be explained later.Tool
"Place" writing and "tools" to execute a JAVA program made separately. Typically, use notepad to write programs that will be stored in .JAVA extension. Then, be compile and executed using the command prompt.There are several tool which makes them into a unity. For example, JCreator, NetBeans, or Visual J ++. With tools, we can write a program, compile and execute with a "tool".
Actually, it is not advisable to use tools in the writing program. With tools, a lot of which is automatic. So, we become spoiled and will not understand the basic concepts of Java programming.
Problems complained mostly students and students when learning basic Java programming is on understanding Object Oriented Programming (OOP). Before discussing more about OOP, will be discussed first "how to start" learning to program with the Java programming language.
Software
The use of software to prepare the Java Development Kit as Virtual Machine. Java Development Kit (JDK) can be downloaded for free. JDK and installation instructions can be found in http://www.oracle.com/technetwork/java/javase/downloads/index.htmlTo type a program code can be used notepad. Once the program is completed typed, the file is saved with the extension of Java. For compile and the execution of the program, use the command prompt.
Jar
JAVA programs can be made "stand alone". The trick is to create a program with the extension jar. Jar file can be created manually. But, for the more easy it can be to use Netbeans. Netbeans is not a paid software, can be downloaded from the link earlier.Hello World
As usual, we are always invited to write "Hello World" when starting to learn a new programming language. Similarly, when it began studying the basic Java programming. How to display text to the JAVA programming language? Here is an example of a program that will display "Hello World" on the screen.public class Hello World
{
public static void main (String args [])
{
System.out.println ("Hello World");
}
}
Public Class
Public class is a class that is public, accessible from outside the program. Public class for this program called Hello World. Naming the class file must be the same as the public. So, this file name is Halo Dunia.Java.Print String
The essence of Hello World Java program is to display the string "Hello World". Statement System.out.println ("Hello World"); produce a display Hello World on the screen when executed.Comments
Although we sometimes lazy to write comments on the programs that we make, it is very useful in the future. Classes, methods, variables, and parameters that we make do not always have a name that reflects its function.Example, for a variable length of a square, pp written. For now maybe we can remember. But, one day we can forget what it stands pp. Therefore, it is important to write a comment on a variable line or anything that requires explanation.
To write a short description, beginning with "//". For example, variable length // square. This method is used to write comments written on one line. If the statement is quite long, how to write is by flanking comments with / * and * /. Here is an example of writing.
/ * rectangle is a quadrilateral that has four equal angles is 90 degrees * /
At the time of program execution, the comment will not be displayed. This comment only helps us to understand the commands that exist in the script programs.
Declaration
Variable declaration or method adapted to the needs. If a variable or method it is public, instead of being keyword "public", also written in the body of a public class program. If a variable or method it is private, given the keyword "private" and is written in a particular class that requires a variable or method it.- Examples of writing a public variable, ie public String post.
- For variable private, written tulisan2 private String.
Starting and Ending
In writing the program, usually the agency programs that do a particular process is limited by the "start" and "end". If the pascal used "Begin" and "End", then the Java programming language used "{" and "}".OOP vs Procedural
Java is an object oriented programming language or Object Oriented Programming (OOP). What are the different object-oriented programming language with a procedural programming language such as turbo pascal?Procedural programming languages execute the program sequentially, starting from the first line to the last line of program code. In contrast to object-oriented programming language that has many class or method. The process is not always sequential program execution from the first row to the last row.
Method main is method are executed first. Thus, main method can be considered as method parent. All method or class the other was called here. Example main method is as follows.
public static void main (String args [])
{
System.out.println ("I executed first");
}
Method main this is public. Args parameter (an array) in the form of a string variable. Method This displays the words "I first executed" on the monitor screen.
Object Oriented Programming
Java including Object Oriented Programming language or Object Oriented Programming. OOP programming is usually abbreviated simply is considered "something" as objects that have properties.To make it easier to learn about OOP in a basic understanding of Java programming, example object directed at objects or humans and other living things around us.
Object
Object here is something that has properties. For example, we take the example of a table object. If we call the "table", which comes to our mind is the various kinds of tables with different sizes, colors, and other properties. So, the object is something that has certain properties.Java language is a programming language that is case sensitive. That case sensitive is sensitive to capital or non-capital letters. So, if it is written "Table", will be different from the "table". For the name of the object in the Java language, letters are usually written with a capital letter in the future. In this discussion, we suppose that the table object is written to the "table".
Object instantiation
Table object in question is still not clear. Table where? In a house there are several kinds of tables. For example, there are 4 tables with shapes and different sizes. Dining table, coffee table, child study table, workbench father.Before describing the properties of the object, first we have to declare of each object. Each different table should be given different names as well.
For example, Mr. Andi had 4 children named Ana, Bona, Cici, and Dodo. Each has a desk. To study table Ana, Bona, Cici, and Dodo each named mba, MBB, mbc, and mbd.
Giving the name of each object in the Java programming called instantiation. Here's how the objects instantiated table.
- Meja Mba = new Table ();
- Meja MBB = new Table ();
- Meja Mbc = new Table ();
- Meja Mbd = new Table ();
For another instance of the object table as well as how to write it.
- Meja Mm = new Table (); // dining table
- Meja Mt = new Table (); // coffee table
- Meja Mk = new Table (); // workbench father
From the few examples given, visible object or objects that have been instant and written with the non-capital letters. Try the instant object naming is not too long. Maximum 3 letters only because instant later the object name will be written over and over again.
For those of you who do coding by using the tool, will not be too bothered. But, for those who write program code using notepad, be quite tiring. However, again I remind you, is not recommended to use tool when you're trying to understand the basic Java programming.
Method
Method can also be interpreted as a method or means. Tables with different sizes produce different volumes. How to calculate the volume of a table called method. If the pascal language we know the procedure or function, the well known Java method.Java programming can be more easily developed if the understanding of the basic concepts of Java programming is quite strong. Therefore, strengthen basic understanding of OOP concepts. Hopefully the correlation between Java programming with objects around us in this article can help you to more easily understand the basic Java programming.