CSE 8A Chapter Notes - Chapter 11.1-11.2: Memory Address

23 views3 pages

Document Summary

To identify the classes to be used in a program, look at the nouns you use to describe it. Simple data becomes fields of a class. Defining a student class public class student. We are declaring a public class called student. All methods, fields, and constructors should be within the {} This class will be saved in a file called student. java. Adding fields: pri(cid:448)ate tri(cid:374)g (cid:374)a(cid:373)e = (cid:862)bla(cid:374)k(cid:863), declare them by specifying visibility, type, and field name, private object can control its own data, and no other object can alter it. Always make fields private: fields automatically initialized if not declared specifically. Booleans false public class student { // fields private string name; private double[] gradearray; We have created a class named student. Each student object will have 2 fields: a name and gradearray. The code above will print out the hash code of the object. Hash code tells if 2 o(cid:271)je(cid:272)ts are the sa(cid:373)e; o(cid:271)je(cid:272)t"s (cid:373)e(cid:373)ory address.

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