COP 4331 - PowerPoint PPT Presentation

About This Presentation
Title:

COP 4331

Description:

degrees Fahrenheit is ...'); // To convert Fahrenheit into Celsius // Begin by subtracting 32 ... System.out.println(fah ' degrees Celsiusn'); TYJ Day 2 Basics.1 ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 11
Provided by: roybl
Learn more at: https://www.cse.fau.edu
Category:
Tags: cop | celsius | fahrenheit | to

less

Transcript and Presenter's Notes

Title: COP 4331


1
COP 4331 OODP
  • Lecture 2

2
Basic Program Structure
  • class Weather
  • public static void main(String arguments)
  • float fah 86
  • System.out.println(fah
  • " degrees Fahrenheit is ...")
  • // To convert Fahrenheit into Celsius
  • // Begin by subtracting 32
  • fah fah - 32
  • // Divide the answer by 9
  • fah fah / 9
  • // Multiply that answer by 5
  • fah fah 5
  • System.out.println(fah " degrees
    Celsius\n")
  • //

3
TYJ Day 2 Basics.1
  • Basic elements of a program
  • Language elements
  • Variable names
  • Declarations
  • Data Types
  • Initialization
  • Constants (final variables)
  • Comments
  • // to end of line
  • / delimited /

4
TYJ Day 2 Basics.2
  • Operators
  • Classes of operators
  • Arithmetic Operators
  • Relational and Conditional Operators
  • Shift and Logical Operators
  • Assignment Operators
  • Other Operators
  • Expressions, Statements, Blocks

5
TYJ Day 4 Flow Control
  • Flow Control
  • General Issues
  • The while and do-while Statements
  • The for Statement
  • The if/else Statements
  • The switch Statement
  • Branching Statements

6
TYJ Day 3 Working with Objects
  • Creating Objects
  • Declaration, Instantiation, Initialization
  • Component reference
  • Class (static) variables methods
  • Can also use ClassName.field
  • Garbage Collection and finalizers

7
TYJ Day 3 Casting
  • Casting numeric primitives
  • (typename) value
  • returns value with new type
  • Casting Classes
  • (classname) object
  • Treat object as having specified class
  • Must be a superclass of the object

8
TYJ Day 3 Converting
  • Convert primitive to corresponding class
  • Class is generally same name, capitalized
  • Exceptions Integer, Character
  • Recover value with accessor typeValue()
  • Example
  • Integer dataCount new Integer(i)
  • int newCount dataCount.intValue()

9
TYJ Day 3 Comparing Objects Identifying Class
  • Comparison with
  • Is it the same object?
  • Use equals method to compare value
  • See EqualsTest
  • Identify class of an object
  • getClasss(), getClass().Name()
  • Compare classes with
  • Instanceof binary operator

10
TYJ Day 4 - Arrays
  • Arrays
  • Creating and Using Arrays
  • Multidimensional array is array of arrays
  • Rows are not necessarily of same length
  • Arrays of Objects
  • Arrays of Arrays
  • Copying Arrays
Write a Comment
User Comments (0)
About PowerShow.com