INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introducing JavaScript
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 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
 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.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Introduction to a Programming Environment
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Introducing Java.
Chapter 1 Coding Introduction.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
A First Program Using C#
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Chapter 1: Creating Java Programs
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Java: Chapter 1 Computer Systems Computer Programming II.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
1 Chapter 2 First Java Programs Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
POS 406 Java Technology And Beginning Java Code
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Programming Concept Chapter I Introduction to Java Programming.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Introduction To JAVA By Ihtesham Ul Haq. Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Introduction to programming in the Java programming language.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Chapter 1 Coding Introduction.
Chapter 1 – Introduction
Introduction to Java Import Scanner class to use in our program
Dept of Computer Science University of Maryland College Park
TRANSLATORS AND IDEs Key Revision Points.
Chapter 1 Coding Introduction.
String Output ICS 111: Introduction to Computer Science I
Fundamentals of Programming
How to Run a Java Program
Programming.
(Computer fundamental Lab)
Presentation transcript:

INTRODUCTION Chapter 1 1

Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts No writing code VL did it behind scenes  Java Writing code High-level language

High-level Programming Languages CPSC 1100 University of Tennessee at Chattanooga 3  Began to appear in mid 1950s  English like  Programmer expressed the idea  You biggest job  Solve the problem at hand  Special program translated into machine language - compiler

Java Example CPSC 1100 University of Tennessee at Chattanooga 4 If (intRate > 100) System.out.println(“Interest rate error”); If the interest rate is over 100, display an error message. What will be displayed is “Interest rate error”

Java Programming Language CPSC 1100 University of Tennessee at Chattanooga 5  Began in 1991  James Gosling and Patrick Naughton at Sun Microsystems  Originally called Green  Designed to be used in consumer devices not as a main line programming language  No customer was found  1994 – rewrote into current browser based Java

Java Features CPSC 1100 University of Tennessee at Chattanooga 6  Lots of code already written to perform routine tasks  Portable code  Not dependent on a specific architecture  Designed for Internet  Built in security features

Technicality CPSC 1100 University of Tennessee at Chattanooga 7  There is a certain structure that must be followed  Some will be explained as we go  Some will have to wait till we understand more

IDE CPSC 1100 University of Tennessee at Chattanooga 8  Integrated Development Environment  Write and test your commands in one location  We will use Blue Jay in lab

Understanding Files and Folders CPSC 1100 University of Tennessee at Chattanooga 9  File – collection of items of information  Programs are kept in files  Should end in.java  Example Test.java  Names can not contain spaces  Case sensitive Test.java not = test.java  Keep you files and back them up  Do not store on the computer

Java Hello World Example CPSC 1100 University of Tennessee at Chattanooga 10

Simple Program CPSC 1100 University of Tennessee at Chattanooga 11 public class HelloTester { public static void main(String[] args) { // Display a greeting in the console window System.out.println("Hello, World!"); } Output: Hello, World!

Java Program CPSC 1100 University of Tennessee at Chattanooga 12  Case sensitive  Caps and lower case do matter  Variable1 different from variable1  Free-form layout  White space doesn’t matter  Looks for ; to say it’s the end of a line  Can string lines together Not recommended I’ll take off points  Code needs to be indented

Java Speak CPSC 1100 University of Tennessee at Chattanooga 13  Visual Logic gives foundation for logic  Java will be programming  We will use different words  We will define things in terms of classes and methods  Don’t let the words throw you off.

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 14  public class HelloTester  Starts a new class  Designated by the word class  Every program consists of one or more classes Generally more than one  Will study classes in the next chapter  For now accept that this is a class

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 15  public class HelloTester  public  Designates who can use the class  Usable by everyone  Another case of we will explain later

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 16  public class HelloTester  HelloTester  Class name  HelloTester must be contained in a file HelloTester.java  The class name and the file name must match  Remember – capitalization counts

Simple Program CPSC 1100 University of Tennessee at Chattanooga 17 public class HelloTester { public static void main(String[] args) { // Display a greeting in the console window System.out.println("Hello, World!"); }

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 18 public static void main (String[] args) { } Defines a method called main A method contains a collection of programming instructions that describe how to carry out a particular task Every java application must have a main. Most have additional methods

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 19 public static void main (String[ ] args) String[ ] args Required part of the main method Command line arguments Allows us to give program information it needs to run The () indicates that what is contained inside is an argument Sometimes they are empty Will discuss details later (much later)

Dissect Simple Program CPSC 1100 University of Tennessee at Chattanooga 20 public class HelloTester { public static void main(String[] args) { } So far all this code does is build a framework! It really doesn’t perform any action that you can see or know is being done. The book calls it the plumbing! This piece of code is necessary to add code to perform an action.

The Simple Program Heart CPSC 1100 University of Tennessee at Chattanooga 21 // display a greeting in the console window This particular line is a comment. It is designed to help the programmer know what is happening with a piece of code. No execution takes place. It is not executed by the compiler. It is a good idea to comment you code. I require it! The comments are generally for blocks of code and not individual lines.

The Simple Program Heart CPSC 1100 University of Tennessee at Chattanooga 22 System.out.println("Hello, World!"); This is where your action takes place. Need to specify the output is to go to the console.

The Simple Program Heart CPSC 1100 University of Tennessee at Chattanooga 23 System.out.println("Hello, World!"); System.out is what is called an object. println is a method telling Java what is to be done to the object System.out “Hello World!” is a parameter being passed to System.out that tell it what to print to the console.

Analogy CPSC 1100 University of Tennessee at Chattanooga 24  System.out is an object  Pen is an object  println is a method or what the object is to do  Write is an method or what the object is to do  (Hello, World!) is the parameter that tells us to write the words Hello, World!

Variables CPSC 1100 University of Tennessee at Chattanooga 25  Java is what is called a typed language.  That means we have to tell the computer what kind of variables we are going to have.  Remember in Visual Logic we just assigned a string or an integer to a variable and it was ok.  Not so in java.  We have to tell it what kind of variable we have.  Different kinds of variables behave differently.  Let’s look at some examples.

What Will These Print? CPSC 1100 University of Tennessee at Chattanooga 26  System.out.println(3+4); 77  System.out.println(“3+7”);  3+7  System.out.print(“00”);  System.out.println(7);  007  System.out.println(“Hello”);  System.out.println(“World”);

Errors CPSC 1100 University of Tennessee at Chattanooga 27  What happens when you make a typo?  Depends  Compile-time or syntax error Think of these types as grammar errors in English  Logic error Think of these as word problems in Math

Syntax Error CPSC 1100 University of Tennessee at Chattanooga 28 System.ouch.println(“Hello World!”): ouch – misspelling – flag by compiler – error message : – should be ; – may or may not compile

Logic Error CPSC 1100 University of Tennessee at Chattanooga 29 System.out.println (“Hello, Word!”); This one will compile and will run. You won’ t get the results you want! These types are more difficult to find and fix!

CPSC 1100 University of Tennessee at Chattanooga 30 Making the Program run

Java and BlueJ CPSC 1100 University of Tennessee at Chattanooga 31  Free software  Must download Java before BlueJ  Java go to  You want to download the JDK NOT the JRE.  Java SE Development Kit (JDK) Bundles  JDK 6 Update 20 with Java EE  BlueJ go to