8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.

Slides:



Advertisements
Similar presentations
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
Advertisements

Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
Chapter 1 Introduction to JAVA. Why Learn JAVA? Java is one of the fastest growing programming language in the world. Java is one of the fastest growing.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter2: Introduction to Java Applications 1.
Chapter 1: Introduction
Chapter 2 - Introduction to Java Applications
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
CMT Programming Software Applications
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Chapter 2 - Introduction to Java Applications
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Comments are for people Header comments supply basic information about the artifact.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
3 Major Steps for Creating/Running a Java Program You write the source code for the program and save it as a.java file. You compile the.java program using.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Chapter 2: Java Fundamentals
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
Introduction to Java Applications Part I. In this chapter you will learn:  Why Java?  History of Java.  To write simple Java applications. 2.
Java FilesOops - Mistake Java lingoSyntax
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
CSC 110 – Intro to Computing - Programming
CS 177 Recitation Week 1 – Intro to Java. Questions?
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to programming in java
CSC201: Computer Programming
Chapter 3 GC 101 Java Fundamentals.
Chapter 2, Part I Introduction to C Programming
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 2 - Introduction to Java Applications
Java Intro.
Computer Programming-1 CSC 111
Presentation transcript:

8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment –2.0 platform

Machine Languages natural language of the computer numeric language hard to read (for humans) EX:

Assembly Languages abbreviations replace some machine language programs called assemblers translate assembly language into machine code EX:LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

High-Level Languages look more like human languages programs called compilers convert high-level code into machine language structured & object-oriented –structured: Pascal, C –structured & object-oriented: Java, C++

Disciplined approach Clearer to read & debug than previous programming styles Pascal, C Ratherthan de cidnbyrs lf hw2use language, you agree to abide by certain conventions to help in collaboration and usability. Structured Programming

Object-Oriented Programming A OOP program has objects that can perform actions on other objects. EX: –newspaper editor, researcher, writer, layout designer –restaurant cook, maitre d’, waiter, dishwasher, customer

OOP Terminology Objects –program construction w/ associated data & actions –EX: a flat head screwdriver Methods –actions that objects can do –EX: turn screws, pry, chisel Classes –sets of similar objects -- all objects have same kinds of data & same methods –EX: lots of screwdrivers that look and act the same.

Java Environment Edit (we’ll use Symantec Visual Café) Compile (javac creates.class file from.java file) Load (java class loader puts.class file into the computer’s memory) Verify (bytecode verifier to ensure security, etc.) Execute (interpreter begins running the program)

Our First Java Program // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } }

Comments // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } Must start with // for a single-line comment

White space: it doesn’t matter. // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } White space is empty space in the program. You can put as many spaces between words as you like.

Class Definition // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } Defines new class called Welcome1 that is public. The class name (by convention) should be capitalized, and MUST be the same as the name of the file (case-sensitive).

Braces // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } Braces (squiggly parentheses) must enclose everything about a class. MUST be paired.

Methods // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } Methods are sets of instructions, or actions to be performed.

Methods // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } public refers to access permissions. void refers to what will be returned from the method (the output).

Methods // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } main is the name of the method. (String args[] ) defines the parameters for the method.

Method Definition Body // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } Entire method body MUST be surrounded by braces.

Method Definition // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } System.out.println prints the string “Welcome!” and then moves the cursor down to the next line. println uses the string “Welcome!” as its argument. println will print a string, then move to the next line. The similar method print will print a string and NOT move to the next line.

Method Definition // Fig. 2.1: Welcome.java // A first program in Java public class Welcome1 { public static void main ( String args[] ) { System.out.println ( “Welcome!” ); } } A statement is an action; a function. They work like sentences. All statements MUST end with a semicolon.

Second Java Program: pg. 42 // Fig. 2.3: Welcome2.java // Printing a line with multiple statements public class Welcome2 { public static void main ( String args [] ) { System.out.print ( “Welcome to” ); System.out.print ( “ Java Programming!” ); } }

Second Java Program: pg. 42 // Fig. 2.3: Welcome2.java // Printing a line with multiple statements public class Welcome2 { public static void main ( String args [] ) { System.out.print ( “Welcome to” ); System.out.print ( “ Java Programming!” ); } } comments Class definition header Class body Method header Method name statements brackets

Escape Sequences Inline character sets that do basic things with text. \nnewline. Moves cursor to next line. \ttab. Moves cursor to next “tab stop” \rreturn.Moves cursor back to start of line. \\backslash. Prints a backslash character. \”double quote. Prints a double quote character. \’single quote. Prints a single quote character.

Third Java Program: pg. 42 // Fig. 2.4: Welcome3.java // Printing multiple lines with one statement public class Welcome3 { public static void main ( String args [] ) { System.out.print ( “Welcome to\nJava!” ); } } comments Class definition header Class body Method header Method name statement brackets

Next Time: Welcome4.java Identifiers Import statements Getting out of the MSDOS window: dialog boxes