Read full document

Java

By | April 2011
Page 1 of 18
Module 2: Basic Java Programming Language
•Sun Certified Programmer for the Java 2 Platform, Standard Edition 1.2 •Sun Certified Business Component Developer for java 2 Platform, Enterprise Edition 1.3 •IBM Test 486 Enterprise Connectivity with J2EE 1.3 •IBM Test 287 Enterprise Application Development with IBM WebSphere Studio, V5.0

BrainStream Co., Ltd.,

Agenda
l Language Fundamentals l Operators and Assignments l Flow Control

BrainStream Co., Ltd.,2

Source Files
l All Java source files must end with ".java" l Source file should contain, at most, one top-

level public class definition. l if a public class is present, class name should match the unextended filename. Demo.java public class Demo{} class Ok{} class Yes{}
BrainStream Co., Ltd.,3

Top-Level Elements
l

1. 2. 3.

These elements are not required. If they are present, then they must appear in order: Package declaration package javafun.lab2; Import java.util.Vector; Import statements import java.awt.*; Class definitions public class Demo{ } Demo.java

BrainStream Co., Ltd.,4

Package
l Package: source placed in directory

hierarchy that reflects package names.
package javafun.lab2; Import java.util.Vector; import java.awt.*; public class Demo{ } Demo.java

BrainStream Co., Ltd.,5

Package
Current Directory C:\

Change to E:\

BrainStream Co., Ltd.,6

Class Path
l Use Jar file in class-path “c:\utils.jar”
utils.jar

BrainStream Co., Ltd.,7

Class Path
l Use –classpath “.” means current directory.
Current Directory C:\

utils.jar

BrainStream Co., Ltd.,8

Package Recommendation
l .
– – –

com.ibm.jvm.* com.ibm.jvm.util.* org.omg.* com.brainstream.iself.* com.brainstream.iself.applet.* com.brainstream.iself.servlet.* BrainStream Co., Ltd.,9

l .
– – –

Import
l Import: either an individual class &

package.

package javafun.lab2; import java.awt.*; import java.util.Vector; public class Demo{ } Demo.java BrainStream Co., Ltd.,10...
Hide

Rate this document

What do you think about the quality of this document?

Share this document

Let your classmates know about this document and more at Studymode.com