Object Oriented Programming Lecture 2: BallWorld.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
Java Syntax Primitive data types Operators Control statements.
BASIC JAVA. Hello World n // Hello world program public class MyFirstJavaProgram { public static void main(String args[]) { char c = 'H'; String s =
1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed.
Netprog 2002 Java Intro1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CSC Java Programming, Fall, 2008 Week 2: Java Data Types, Control Constructs, and their C++ counterparts, September 4.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
From C++ to Java A whirlwind tour of Java for C++ programmers.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
Chapter 2: Java Fundamentals
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
Page: 1 การโปรแกรมเชิงวัตถุด้วยภาษา JAVA บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 15 มิถุนายน 2552 Keyword & Data Type มหาวิทยาลัยเนชั่น.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
1 Programming Java Java Basics. 2 Java Program Java Application Program Application Program written in general programming language Applet Program running.
Primitive data Week 3. Lecture outcomes Primitive data – integer – double – string – char – Float – Long – boolean Declaration Initialisation Assignments.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Mixing integer and floating point numbers in an arithmetic operation.
August 6, 2009 Data Types, Variables, and Arrays.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
Java Programming Java Basics. Data Types Java has two main categories of data types: –Primitive data types Built in data types Many very similar to C++
Copyright Curt Hill Variables What are they? Why do we need them?
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
“Great leaders are never satisfied with current levels of performance. They are restlessly driven by possibilities and potential achievements.” – Donna.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
Programming in java Lecture-3 (a). Java Data Type TypeDescription byte8 bit signed integer short16 but signed integer int32 bit signed integer long64.
Lecture 07. Do not have to create an array while declaring array variable [] variable_name; int [] prime; int prime[]; Both syntaxes are equivalent No.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
CSC Java Programming, Spring, 2010 Week 2: Java Data Types, Control Constructs, and their C++ counterparts.
LESSON 5 – Assignment Statements JAVA PROGRAMMING.
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
Java Computer Industry Lab. 1 Programming Java Java Basics Incheon Paik.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Spring 2006 Special Topics in Computer Engineering: Java Intro 1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J.
Java Programming Language Lecture27- An Introduction.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Intro to ETEC Java.
Chapter No. : 1 Introduction to Java.
Lecture 2: Data Types, Variables, Operators, and Expressions
An Introduction to Java – Part I
5 Variables, Data Types.
An Introduction to Java – Part I, language basics
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Java Programming Review 1
Java Basics Data Types in Java.
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

Object Oriented Programming Lecture 2: BallWorld

1 st Java A first Java program (outline) import java.lang.*; public class Test { public static void main(String [] args) { System.out.println("Hello"); }

Running Java is interpreted – The Java interpreter must be installed The Java ‘compiler’ is called ‘javac’ The Java interpreter is called ‘java’

Java 1 Declarations – Primitive types int 32 bit signed integer byte 8 bit signed integer short 16 bit signed integer long 64 bit signed integer float 32 bits double 64 bits char 16 bits (Unicode) boolean No typedef No struct, have class No (explicit) pointers (references instead)

String String is a built-in type (note the capital S) Many functions ‘+’ for concatenation ‘toString’ methods for conversion Conversions often automatic int x = 123; float y = 23.66f; System.out.print ("Hello " + x + " and " + y);

Java 2 Arrays are always dynamic (a.length) int [] a; int a[]; // alternative a = new int[10]; // allocate int i; for (i = 0; i < 10; i++) a[i] = ……; for (i = 9; i >= 0; i--) System.out.println( "a[" + i + "] = " + a[i]); a = null; // no deallocate

Java 2 Multi-dimensional arrays int [] [] a; int a[][]; // alternative a = new int[10][20]; a[1][7] =...; a = new int [10] []; a[0] = new int[10]; a[1] = new int[11];

Java 3 Statements are the same as C/C++ – if, switch (case, break), for, while – Assignment Expressions also similar to C/C++ – type cast using (char)10 style notation Routines as for C/C++ – return Exception handling used more often – throw, try and catch – see later

Exercises Chapter 4 Questions on page 63 – 2, 9 to 14 Exercises on pages – 2 to 5 Write a program taking two integers as command line arguments and drawing an outline rectangle of ‘*’ characters of the given size. To be verified: Pg 63: Q and the rectangle programming exercise