Ch2 - EE322C DataStructures Chapter2:ReferenceTypes...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Ramesh Yerraballi 2-1 EE 322C Data Structures Chapter 2:Reference Types
Background image of page 1

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

View Full DocumentRight Arrow Icon
Ramesh Yerraballi 2-2 Reference Type - Defined All types that are not one of the 8 primitive  types are  Reference  types. Reference  type is a variable that stores the  memory address of an  Object Java does not allow a Reference type to store the  memory address of a primitive type 1000 (0, 0) 1024 (5, 12) 3200 point2 = 1024 3600 point1 = 1000 5124 Point3 = 1000 point1 point3 (0, 0) (5, 12) (at 1000) (at 1024)
Background image of page 2
Ramesh Yerraballi 2-3 Terminology Type Class Variables (aka Fields) Methods o Constructors o Accessors o Mutators Object Reference
Background image of page 3

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

View Full DocumentRight Arrow Icon
Ramesh Yerraballi 2-4 Coding Style - Convention package java.blah; importjava.blah.blahdy.BlahBlah; /** * Class description goes here . * * @version 1.0 Sept 2008 * @author Firstname Lastname */ public class Blah extends SomeClass { /* Implementation comment can go here. */ /** classVar1 documentation comment */ public static int classVar1; /** * classVar2 documentation comment * that happens to be * more than one line long */ private static Object classVar2; /** instanceVar1 documentation comment */ public Object instanceVar1; /** instanceVar2 documentation comment */ protected int instanceVar2; /** instanceVar3 documentation comment */ private Object[] instanceVar3; /** * . .. constructor Blah doc comment. .. */ public Blah() { // . ..implementation goes here. .. } /** * . .. method doSomething doc comment. .. */ public void doSomething() { // . ..implementation goes here. .. } /** * . ..method doSomethingElse doc comment. . * @param someParam description */ public void doSomethingElse(Object someParam) { // . ..implementation goes here. .. } }
Background image of page 4
Ramesh Yerraballi 2-5 Operations on References Permitted On reference itself 1. Assignment ( = ) greet = new String(“Hi”); 2. Comparison ( != == ) if (pt1 != null) pt2 = pt1; if (pt1 == pt2) do_sth(); On object referred to: 1. Dot Operator ( . ) double ar = acircle . area(); 2. Check type ( instanceof ) if (aref instanceof Herbivore) aref.eatGrass(); else aref.eatMeat(); 3.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Ch2 - EE322C DataStructures Chapter2:ReferenceTypes...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online