Pemrograman Dasar

skatechildrenSoftware and s/w Development

Nov 3, 2013 (3 years and 7 months ago)

162 views

JAVA

PROGRAMING LANGUAGE

Content of Java 2 SDK


Development Tools



(In the bin subdirectory.) Tools and utilities that will help you develop, execute, debug, and
document programs written in the Java programming language. For further information, see
the
tool documentation
.



Runtime Environment



(In the jre subdirectory.) An implementation of the Java 2 runtime environment for use by the
SDK. The runtime environment includes a Java virtual machine, class libraries, and other files
that support the execution of programs written in the Java programming language.



Additional Libraries



(In the lib subdirectory.) Additional class libraries and support files required by the
development tools.



Demo Applets and Applications



(In the demo subdirectory.) Examples, with source code, of programming for the Java
platform. These include examples that use Swing and other Java Foundation Classes, and the
Java Platform Debugger Architecture.



C header Files



(In the include subdirectory.) Header files that support native
-
code programming using the
Java Native Interface
, the
Java Virtual Machine Debugger Interface
, the
Java Virtual Machine
Profiler Interface

and other functionality of the Java 2 Platform.



Source Code



(In src.zip.) Java programming language source files for all classes that make up the Java

2
core API (that is, sources files for the java.*, javax.* and some org.* packages, but not for
com.sun.* packages). This source code is provided for informational purposes only, to help
developers learn and use the Java programming language. These files do not include platform
-
specific implementation code and cannot be used to rebuild the class libraries. To extract
these file, use any common zip utility. Or, you may use the Jar utility in the Java 2 SDK's bin
directory: jar xvf src.zip

J2SE Directory Structure

Example / Demo


Helloworld


Applet

Language Basic


The BasicsDemo program adds the numbers
from 1 to 10 and displays the result.


The output from this program is: Sum = 55


Basic demo program uses many of the traditional
features of the Java programming language,
including
variables
,
operators
, and
control flow
statements


public class BasicsDemo {


public static void main(String[] args) {


int sum = 0;


for (int current = 1; current <= 10; current++) {


sum += current;


}


System.out.println("Sum = " + sum);


}

}

Variable


Definition:


A
variable

is an item of data named
by an identifier.


The variable's name must be a legal
identifier

--
an unlimited series of Unicode characters that
begins with a letter


We use the variable name to refer to the data
that the variable contains


Variable
declaration



Example : MaxVariableDemo


Scope
:
The section of code where the variable's
simple name can be used. The variable's scope is
determined implicitly by the location of the
variable declaration, that is, where the
declaration appears in relation to other code
elements

type name

Ex: String kata, int bil


Variable Name


In the Java programming language, the following must hold
true for a simple name:


It must be a legal identifier. An identifier is an unlimited series
of Unicode characters that begins with a letter.


It must not be a
keyword
, a boolean literal (true or false), or
the reserved word null.


It must be unique within its scope. A variable may have the
same name as a variable whose declaration appears in a
different scope. In some situations, a variable may share the
same name as another variable if it is declared within a nested
block of code. (We will cover this in the next section, Scope.)


By Convention :


Variable names begin with a lowercase
letter, and class names begin with an uppercase letter. If a
variable name consists of more than one word, the words
are joined together, and each word after the first begins
with an uppercase letter, like this: isVisible. The underscore
character (_) is acceptable anywhere in a name, but by
convention is used only to separate words in constants
(because constants are all caps by convention and thus
cannot be case
-
delimited)

Keyword