Java Learning Made Easy

Comenzar desde el principio
                                        

n Enclosure of the program in a class

definition.

n Enclosure of the body of the program in

the functions.

attention@computerscienceexpertise.com PDF created with pdfFactory Pro trial version www.pdffactory.com

Example Program in JAVA

class exampleprogram

{

public static void main(string args[ ])

{

System.out.println(“Hail The World !”);

}

}

attention@computerscienceexpertise.com PDF created with pdfFactory Pro trial version www.pdffactory.com

In the above program, the first line

class exampleprogram

class exampleprogram

{public static void main(string args[ ])

{System.out.println(“Hail The World

!”);}}

declares a class named exampleprogram, where class is the reserve word. Exampleprogram is an identifier as supplied by the programmer. This is followed by brace {, which indicates the beginning of the block of executable statements. The third line :

public static void main(string args[ ])

defines the function main( ). The declaration of the main() function contains the following keywords:

Public, Static and Void.

The Public keyword acts as an access specifier which declares the main function to be publically accessible for other classes.

The Static definition declares that the very function or method is independent of the entire class and does not figure as a part of any objects of the class. In the above program, the class exampleprogram is unchanging or static, as a state. The term static means unchanging and implicitly final.

The Void is a data type modifier which defines the main() function of no return type. The argument of the main() function lies within braces eg. (String args[ ]), here String args[ ]

declares an argument parameter a astt

arnt

s n@c

con o

ai p

n ut

in egr sc

a ie

n nace

rr eaxyp eorft is

o eb.jcom

ects of the class type String. It specifies that the main method takes an argument that is an object of string. PDF created with pdfFactory Pro trial version www.pdffactory.com

BlueJ Environment?

To make effective use of

BlueJ, one has to eliminate

the very un-object-oriented

public static void main and

replace it with other function

name so as to instantiate the

object and call the method for

execution.

Has llegado al final de las partes publicadas.

⏰ Última actualización: Sep 25, 2012 ⏰

¡Añade esta historia a tu biblioteca para recibir notificaciones sobre nuevas partes!

Java Learning Made EasyDonde viven las historias. Descúbrelo ahora