CSE 8A Lecture 9: Lecture 9 Notes and Discussion Notes

62 views3 pages

Document Summary

Creating an array int[] intarray = new int[1000]: 1d array. Array properties: first index = 0, can initialize arrays int [] intarray = {1, 5, 8, 70}; intarray[2]; -> gives 8 intarray. length; -> gives 4. Can make an array of objects: bunny[] bunnyarray = new bunny[5]; Initializes an array to be filled with elements of type bunny. Constructors: every time you make a class, you can give the class fields (properties of the class) and behaviors (stuff the class can do, public class song { Public song (string title, string author) { this. title = title: //this. title refers to the caller object this. author = author, //this. author refers to the caller object. The default constructor has no parameters, whereas this one will create. Objects based on the parameters you pass into it ie. ong song = new ong (cid:894)(cid:862)weight in gold(cid:863), (cid:862)gallant(cid:863)(cid:895): this song object will have the properties: title = (cid:862)weight in.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents