Term Project - English Language 2 - Example of Term Project 2

  • Upload
    beee93

  • View
    227

  • Download
    0

Embed Size (px)

Citation preview

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    1/26

    Term ProjectSubject: English Language 4

    Title: JAVA

    2013/0035 Pera PericSupervisor: prof. MiloD.uri

    Faculty of Electrical Engineering

    University of Belgrade

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    2/26

    Introduc t ion to Java

    What Is Java?

    Getting Started With Java Programming

    Create, Compile and Running a JavaApplication

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    3/26

    What Is Java?

    History

    Characteristics of Java

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    4/26

    History

    James Gosling and Sun Microsystems

    Oak

    Java, May 20, 1995, Sun World

    HotJava

    The first Java-enabled Web browser

    JDK Evolutions J2SE, J2ME, and J2EE (not mentioned in

    the book, but could discuss here optionally)

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    5/26

    Character ist ics of Java

    Java is simple Java is object-oriented

    Java is distributed

    Java is interpreted

    Java is robust

    Java is secure

    Java is architecture-neutral

    Java is portable

    Javas performance

    Java is multithreaded

    Java is dynamic

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    6/26

    JDK Vers ions

    JDK 1.02 (1995) JDK 1.1 (1996)

    Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998)

    Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002)

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    7/26

    JDK Edi tions

    Java Standard Edition (J2SE) J2SE can be used to develop client-side standalone

    applications or applets.

    Java Enterprise Edition (J2EE) J2EE can be used to develop server-side applications

    such as Java servlets and Java ServerPages.

    Java Micro Edition (J2ME). J2ME can be used to develop applications for mobile

    devices such as cell phones.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    8/26

    Java IDE Too ls

    Forte by Sun MicroSystems Borland JBuilder

    Microsoft Visual J++

    WebGain Caf

    IBM Visual Age for Java

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    9/26

    Gett ing Star ted w ith Java Programm ing

    A Simple Java Application

    Compiling Programs

    Executing Applications

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    10/26

    A Simp le Appl icat ion

    Example 1.1//This application program prints Welcome

    //to Java!package chapter1;

    public class Welcome {public static void main(String[] args) {System.out.println("Welcome to Java!");

    }

    }

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    11/26

    Creat ing and Compi l ing Prog rams

    On command line javac file.java

    S o u r ce C o d e

    C r e a t e / M o d i fy S o u r c e C o d e

    C o m p i le S o u r c e C o d e

    i .e . j a v a c W e l c o m e . ja v a

    B t e co d e

    R u n B y t eo d ei .e . j a va W e l c o m e

    R e s u l t

    I f c o m p i la t i o n e r r o r s

    I f r u n t im e e r r o r s o r i n c o r r e c t r e s u l t

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    12/26

    Execut ing Appl icat ions

    On command line java classname

    JavaInterpreter

    on Windows

    JavaInterpreter

    on Sun Solaris

    JavaInterpreter

    on Linux

    Bytecode

    ...

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    13/26

    Example

    javac Welcome.java

    java Welcome

    output:...

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    14/26

    Compi l ing and Running a Program

    c:\exampl

    chapter1 Welcome.class

    Welcome.java

    chapter2

    .

    .

    Java source files and class files for Chapter 2

    chapter19 Java source files and class files for Chapter 1

    Welcome.java~

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    15/26

    Anatomy o f a Java Program

    Comments Package

    Reserved words

    Modifiers

    Statements

    Blocks

    Classes

    Methods

    The main method

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    16/26

    Comments

    In Java, comments are preceded by two

    slashes (//) in a line, or enclosed

    between /* and */ in one or multiple

    lines. When the compiler sees //, itignores all text after // in the same

    line. When it sees /*, it scans for the

    next */ and ignores any text between /*

    and */.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    17/26

    Reserved Words

    Reserved wordsor keywordsare wordsthat have a specific meaning to thecompiler and cannot be used for other

    purposes in the program. For example,when the compiler sees the word class,it understands that the word after classis the name for the class. Otherreserved words in Example 1.1 are

    public, static, and void. Their use willbe introduced later in the book.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    18/26

    Modi f iers

    Java uses certain reserved words calledmodifiersthat specify the propertiesof the data, methods, and classes and

    how they can be used. Examples ofmodifiers are public and static. Othermodifiers are private, final, abstract,and protected. A public datum, method,or class can be accessed by other

    programs. A private datum or methodcannot be accessed by other programs.Modifiers are discussed in Chapter 6,"Objects and Classes."

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    19/26

    Statements

    A statementrepresents an action or a

    sequence of actions. The statement

    System.out.println("Welcome to Java!") in

    the program in Example 1.1 is a statement

    to display the greeting "Welcome toJava!" Every statement in Java ends with

    a semicolon (;).

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    20/26

    Blocks

    A pair of braces in a program forms a

    block that groups components of a

    program.

    public class Test {

    public static void main(String[] args) {

    System.out.println("Welcome to Java!");

    }

    }

    Classbloc

    Methodbloc

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    21/26

    Classes

    The classis the essential Java construct.

    A class is a template or blueprint for

    objects. To program in Java, you must

    understand classes and be able to writeand use them. The mystery of the class

    will continue to be unveiled throughout

    this book. For now, though, understand

    that a program is defined by using one or

    more classes.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    22/26

    Methods

    What is System.out.println? It is amethod: a collection of statements thatperforms a sequence of operations todisplay a message on the console. It can

    be used even without fully understandingthe details of how it works. It is used byinvoking a statement with a stringargument. The string argument is enclosedwithin parentheses. In this case, the

    argument is "Welcome to Java!" You cancall the same println method with adifferent argument to print a differentmessage.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    23/26

    main Method

    The main method provides the control ofprogram flow. The Java interpreterexecutes the application by invoking themain method.

    The main method looks like this:

    public static void main(String[] args) {

    // Statements;

    }

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    24/26

    Displaying Text in a Message Dialog

    Box

    you can use the showMessageDialog method in

    the JOptionPane class. JOptionPane is one of

    the many predefined classes in the Javasystem, which can be reused rather than

    reinventing the wheel.

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    25/26

    The showMessageDialog Method

    JOptionPane.showMessageDialog(null, "Welcometo Java!",

    "Example 1.2",

    JOptionPane.INFORMATION_MESSAGE));

  • 8/12/2019 Term Project - English Language 2 - Example of Term Project 2

    26/26

    Thank you fo r your attent ion !