06-objects1

06-objects1 - COMP 202 Built-in Libraries and objects...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 1 COMP 202 Built-in Libraries and objects CONTENTS : •Introduction to objects •Introduction to some basic Java libraries String Random other APIs
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 2 Classes and Objects • An object is an entity that has data and methods – so far, we haven’t seen data, only methods – examples: • teller machine objects that allow to withdraw money, make money transfers etc. • calculator objects that allows to perform addition, division, etc. • Scanner objects allow to read in data from the keyboard
Background image of page 2
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 3 Classes and Objects • Each object belongs to a class – Examples • teller machine objects belong to the class teller machine • A scanner object belongs to the class Scanner – All objects of a class have the same methods Scanner objects have nextInt(), nextDouble(), • teller machine objects have withdraw,… • A class can be seen as a blueprint which describes the general behavior of a set of similar objects • That is, the class used to define an object can be thought of as the type of an object
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 4 About Libraries • Programming languages come with many components: – Editor To help you write the program – Compiler To validate your syntax and convert you text file into an executable file – Syntax & Semantics Rules that define how you write sentences and spell words in that language – Libraries Pre-built classes and objects with methods that you can use in your program (this is nice since you do not need to write this code, someone else has done this for you). Libraries come with the compiler you buy or you can download them from the web (some free, some not).
Background image of page 4
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 5 System.out System.out is a variable that points to an object that belongs to the class PrintStream System.out has been predefined and set up for us as part of the Java standard class library. println is a method that has been implemented by someone else. We don’t care what actions or statements are actually executed. We only need to know what it is supposed to do and what the input is. System.out.println (”This is a long message to print in a single line."); ±bje²T vaR³able ´eTh±D µNf±R´aT³±N¶·R±v³DeD¶T±¶The¶´eTh±D (·aRa´eTeRs)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
COMP 202 – Introduction to Computing 1 COMP 202 - Objects and Built-in Libraries 6 The DOT Operator • Java uses the period as a membership designation. • For example:
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 44

06-objects1 - COMP 202 Built-in Libraries and objects...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online