Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Usage Review...again. Creating a new instance What is a reference variable? All objects except for primitive variables are reference variables.

Similar presentations


Presentation on theme: "Object Usage Review...again. Creating a new instance What is a reference variable? All objects except for primitive variables are reference variables."— Presentation transcript:

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


Download ppt "Object Usage Review...again. Creating a new instance What is a reference variable? All objects except for primitive variables are reference variables."

Similar presentations


Ads by Google