Turtles in Java

Turtles in Java - Turtles in Java Defining Turtles write a...

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

View Full Document Right Arrow Icon
Turtles in Java Defining Turtles - write a Turtle class definition o store as Turtle.java - compile into something computer understands o byte code can be executed on a virtual machine Creating objects - object that defines it must create it - need a unique way to refer to it o declaring a variable - keyword: new ClassName - initialize the object to actually use it o all of the variables that define the state of the object (shape, color, etc) - syntax for new object: new Class (value, value, …); - must have a name for new object in order to refer to it o gives us a way to work with the names and find it again Declaring variables - give it a name o should be unique to the variable - declaration just gives name and type but doesn’t create object - computer assigns memory to the variable you declare o amount of memory depends on type of variable o computer stores a map of the name to the memory location and type Limits of Declaring variables - can’t declare two variables of the same name
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

Turtles in Java - Turtles in Java Defining Turtles write a...

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

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