{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Class 16 - Types and Events continued Matthew Hashim Click...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
12/4/09 Click to edit Master subtitle style Types and Events, continued Matthew Hashim 10/20/2009 11
Image of page 1

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

View Full Document Right Arrow Icon
MGMT 290D 12/4/09 Goals for Today n Understand the difference between Java’s fundamental and class types n Build complex Java expressions n Better understand and use Java’s Scanner and PrintStream classes 22
Image of page 2
MGMT 290D 12/4/09 Reference Types n Two distinguishing features of reference types ¨ Reference variable initialization ¨ The encapsulation of behaviors and attributes 33
Image of page 3

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

View Full Document Right Arrow Icon
MGMT 290D 12/4/09 Reference Variable Initialization n Usually involves use of the new operator n new operation ¨ Request memory for an object of the indicated type ¨ Returns a reference to that object n Example of a new operation ¨ Scanner keyboard = new Scanner(System.in) ; ¨ keyboard is a handle to a Scanner object n Exception to the rule: initialization of a String object ¨ Example: String tTwist = "Unique New York"; 44
Image of page 4
MGMT 290D 12/4/09 Reference Variable Initialization (continued) n Comparison with initialization of primitives ¨ Reference type only stores object address (reference) ¨ Primitives store the value indicated by the type n null value: a special zero reference n Reference type set to null does not refer to an object n Example: String tongueTwister = null; n boolean tests can be applied to objects set to null 55
Image of page 5

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

View Full Document Right Arrow Icon
MGMT 290D 12/4/09 Sending Messages n Reference types are classes containing methods n Primitives are not classes and do not contain methods n How to compute with reference types ¨ Send a message to an object n Pattern: referenceVariable.methodName() n Ex: int monthNumber = keyboard.nextInt(); ¨ Send nextInt() to object referenced by keyboard 66
Image of page 6
MGMT 290D 12/4/09 Sending Messages (continued) n Two ways to identify object appropriate messages ¨ Type the name of a handle and a period ¨ Search the method list for the class in the Java API n Java API (application programming interface) ¨ Includes method names, parameters, return types, etc.
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern