$30 off During Our Annual Pro Sale. View Details »

CSE110 Lecture 02

CSE110 Lecture 02

Principles of Programming with Java
Introduction to Java
(202205)

Javier Gonzalez-Sanchez
PRO

May 18, 2017
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. CSE110
    Principles of Programming
    with Java
    Lecture 02:
    Introduction to Java
    Javier Gonzalez-Sanchez
    [email protected]
    javiergs.engineering.asu.edu | javiergs.com
    Office Hours: By appointment

    View Slide

  2. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 2
    Previously…

    View Slide

  3. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 3
    Previously …
    • The Java compiler translates Java source code into
    a special representation called bytecode
    • Java bytecode is not the machine language
    • Another software tool, called an interpreter (Java
    Virtual Machine), translates bytecode into machine
    language and executes it
    • Java is considered to be architecture-neutral

    View Slide

  4. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 4
    Previously…
    • Environments for developing Java software:
    o NetBeans
    o Eclipse
    o TextPad
    o BlueJ
    o IntelliJ
    o www.tutorialspoint.com/compile_java_online.php
    • Though the details of these environments differ, the
    basic compilation and execution process is
    essentially the same

    View Slide

  5. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 5
    Working online

    View Slide

  6. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 6
    Working local | IntelliJ

    View Slide

  7. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 7
    Steps that a programmer takes
    Write a program
    (instructions to a computer)
    Compile the program
    i.e., translate it to machine code
    Execute/Run the program
    i.e., tell the computer to execute
    each instruction
    Fix
    typos,
    grammar errors
    Fix
    logical error
    (semantic)

    View Slide

  8. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 8
    Lab 01
    • Lab 01 will be to install an
    IDE (Integrated Development Environment)
    for Java
    • IDE =
    Text Editor +
    Java Compiler +
    Java Virtual Machine +
    Fancy Tools

    View Slide

  9. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 9
    Java Program Structure
    • A program is made up of one or more classes
    • A class contains one or more methods
    • A method contains program statements

    View Slide

  10. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 10
    Java Program Structure
    public class TheClassName {
    }

    View Slide

  11. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 11
    Java Program Structure
    public class TheClassName {
    }
    public static void theFirstMethodName() {
    }
    public static void secondMethodName() {
    }

    View Slide

  12. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 12
    Example

    View Slide

  13. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 13
    Java Program Structure
    • program statements can be:
    • Variables – places to store information
    • Instructions – actions to be done

    View Slide

  14. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 14
    Java Program Structure

    View Slide

  15. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 15
    Java Program Structure
    public class TheClassName {
    }
    public void theFirstMethodName() {
    }
    public void secondMethodName() {
    }
    // instructions go here
    // instructions go here
    // variables go here
    // variables go here
    // variables go here

    View Slide

  16. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 16
    Reserved Words
    • The Java reserved words:
    abstract
    boolean
    break
    byte
    case
    catch
    char
    class
    const
    continue
    default
    do
    double
    else
    extends
    false
    final
    finally
    float
    for
    goto
    if
    implements
    import
    instanceof
    int
    interface
    long
    native
    new
    null
    package
    private
    protected
    public
    return
    short
    static
    strictfp
    super
    switch
    synchronized
    this
    throw
    throws
    transient
    true
    try
    void
    volatile
    while

    View Slide

  17. Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 17
    Homework
    Read Sections 2.1 and 2.2

    View Slide

  18. CSE110 - Principles of Programming
    Javier Gonzalez-Sanchez
    [email protected]
    Summer 2022
    Disclaimer. These slides can only be used as study material for the class CSE110 at ASU. They cannot be distributed or used for another purpose.

    View Slide