Download presentation
Presentation is loading. Please wait.
Published byAudrey Blatchford Modified over 9 years ago
1
Object Usage Review...again
2
Creating a new instance What is a reference variable? All objects except for primitive variables are reference variables How do we create a new object? 1. Declare the reference variables 2. Assign the reference a new object 3. Use the word new and then a constructor Card myCard = new Card(“Ace”, “Spades”) Contact myContact = new Contact(“John”, “Doe”, “703-867- 5309”)
3
Using an object’s attribute/method Objects possess attributes and methods You access an object’s attributs and methods using the. myArray.length//accessing an attribute myCard.getCardValue()//accessing a method You may access attributes and methods if they are public inside the object Methods may or may not return something
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.