Вы находитесь на странице: 1из 12

IU-VNU-HCM

LOGO

Data Structures and Algorithms


Robert Lafore, Data structures and Algorithms in Java, Waite Group Press, 2002

Lecture 1. Getting Started

Trong Hai Duong, PhD


Email: haiduongtrong@gmail.com
Mobile phone: 0945090908
Homepage: http://co-intelligence.vn

IU-VNU-HCM

Contents
The Java Technology
The Java Platform
The "Hello World!" Application
Editors

IU-VNU-HCM

Company Logo

The Java Technology


Object Oriented
Platform independent
Simple
Secure
Architectural-neutral
Portable
Robust
Multithreaded
Interpreted
High Performance
Distributed
Dynamic

Each of the preceding buzzwords is


explained in
The Java Language Environment

IU-VNU-HCM

Company Logo

The Java Technology


SE (Standard Edition-SDK 7 http
://www.oracle.com/technetwork/java/javase/downloads/index.html)

Notepad: TextPad.
Netbeans: http://www.netbeans.org/index.html.
Eclipse: http://www.eclipse.org/.

Microsoft Windows, the Solaris Operating


System (Solaris OS), Linux, or Mac OS

IU-VNU-HCM

Company Logo

The Java Platform


The Java platform has two components:
The Java Virtual Machine
The Java Application Programming Interface (API)

IU-VNU-HCM

The "Hello World!" Application


Assume tour installed directory is
C:\Program Files\Java\jdk1.7.0_40
Create a directory where you will save your Java
programs call the folder JavaProgs
Start NotePad and enter the program on the next slide.
Save it with the filename HelloWorldApp.java must
be this name. Put quotes around it make sure
Notepad does not put .txt on the end.
Note CAPITAL F.
Save it in your Example
(E:\Lectures\DataStructureAndAlgorithmInJavaHai\Example) folder

IU-VNU-HCM

Company Logo

The "Hello World!" Application

class HelloWorldApp
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}

IU-VNU-HCM

Compiler
The compiler is called javac. Youll need to include
the path to it, so type in:

Then run it like this:

IU-VNU-HCM

NetBeans IDE 7.3.1


Better editor for programming Java
File->New Project->Java->Java Application
Project Name: HelloWorldApp
Create Main Class: HelloWorldApp
Sample skeleton Code is created in
HelloWorldApp.java in First project

IU-VNU-HCM

Company Logo

Eclipse Standard 4.3

IU-VNU-HCM

Notice
Each source code file defines a class
The name of the class it defines (First in our case)
must match the filename hence First.java
This is compiled to a bytecode file named
First.class
Java is case-sensitive (like C)
Classes should start with a capital letter.
Change First.java to first.java
Test with javac first.java
ERROR!
So the file must be called First.java and not
first.java

IU-VNU-HCM

Notice
Java is a pure object-oriented language.
No functions, no global variables
Unlike C++, which is C with objects
Java is designed to make it hard to write programs
which will crash
No pointers
Compiler will not compile doubtful code
Programmer must write code that catches exceptions
Run-time checks eg array bounds exceptions
Slower than C or C++ (not much), but less chance of
crash

Вам также может понравиться