Java is a powerful
object-oriented language that is fun to use para sa mga begginer lalo na sa mga
may karanasan na sa paggawa ng isang substantial information system. Maaari
itong maging language of choice sa pag-implement ng Internet-based o Internet
based applications as well as software for devices that communicate over
networks.
Nagcoconsist ang Java ng
several parts: an environment, the
language, the Java Applications Programming Interface (API), and various class
libraries. Normally, java programs have five phases to be executed. ito ang
edit, compile, load, verify and execute.
Experienced programmers
sometimes take pride in being able to create some weird, contorted, convoluted
usage of a language. This is a poor programming practice. It makes programs
more difficult to read, more likely to behave strangely, mas mahirap din itong
itest at idebug, and more difficult to adapt to changing requirements. Also
maaaring magrun ang any program written in Java sa iba’t ibang unit o computer.
The most problem with the early versions of Java is that the programs execute
interpretively on the client’s machine. Iniinterpret nito ng isa-isa line by
line compared to fully compiled code machine.
Here is a simple program
for printing a line of text.
public class Welcome1
{
public static void
main( String args[] )
{
System.out.println(“Welcome to Java Programming!”);
}
}
Tapos
ito yung magiging output: Welcome
to Java Programming!
Sa pagcocompile ng isang
Java program, we open a command window, baguhin ang directory kung saan
nakastore ang program tapos itype ang java Welcome1.java. Kung ang iyong program ay hindi
nagco-contain ng any syntax error, the preceding command creates a new file na
tinatawag na Welcome1.class containing the Java byte
codes na magre-represent ng application. Ang byte codes na ito ay syang
iiinterpret ng Java interpreter kapag iniexecute na natin ang program by typing
java Welcome1.
Kapag nagkaroon ng isang
syntax error, maaring wala ito sa line na inindicate ng error messages. First,
icheck muna ang line na inindicate ng error messages at kapag hindi ito ang
nagco-contain ng error, sunod naming tingnan para icheck ay ang preceding lines
ng program.
Every program ng Java ay
nagco-consist ng atleast one class definition that is defined by the
programmer. Ang keyword na class ang nag-iintroduce ng class definition ng Java na sya namang
sinusundan ng class
name (Welcome1). Keywords are always
spelled with all lowercase letters.
Laging tandaan na ang
Java ay case sensitive. Ang hindi paggamit ng proper uppercase at lowercase
letters for an identifier ay maituturing na syntax error. You should always
begin a class name with a capital first letter. When reading Java program,
laging tingnan ang identifier na nagsisimula sa capital letters. These normally
represent Java classes. Avoid using identifiers containing dollar sign ($) as
these are often used by the compiler to create identifier names.
public static void main( String args[] ) ---
ito ay part ng every Java application. Automatically java applications begin
executing at main. Ang parenthesis after main ay nag-iindicate na ang main ay
isang program method. The left brace begins the body of the method definition
then the right brace must end the method definition’s body.
System.out.println(“Welcome to Java Programming!”); ---
ito naman ang nag-iinitiate sa computer to print the string of characters contained between the double quotation marks. Maaari
din tawaging character string, a message or a string literal ang string.
System.out is known as the standard output object. It
allows Java applications to display strings and other types of information in
the command window from which the Java application is executed.
System.out.println --- its argument in the
parenthesis and the semicolon is called a statement. Kailangang ang every
statement must end with a semicolon o ang tinatawag na statement terminator.
Kapag naexecute na ito, it now displays the message (Welcome to Java Programming!) in the command window.
by: Camille Abigail M. Rollan
200910643
0 comments:
Post a Comment