7 jan 2019 · OSU CSE 4 boolean char int double (plus 4 others) String XMLTree SimpleReader SimpleWriter NaturalNumber Reference Types
Previous PDF | Next PDF |
[PDF] CSE 2221 - NaturalNumber - OSU CSE
7 jan 2019 · The NaturalNumber component family allows you to manipulate natural numbers (i e , non-negative integers) – Unlike an int variable,
[PDF] CSE 2221 - References - OSU CSE
7 jan 2019 · OSU CSE 4 boolean char int double (plus 4 others) String XMLTree SimpleReader SimpleWriter NaturalNumber Reference Types
[PDF] CSE 2221 - Project 11 - Logan Frank
26 avr 2020 · setEnabled (for JButtons) and setText (for JText) are useful methods • Have the NaturalNumber documentation up while completing this project
[PDF] loop invariant - School of Computing at Clemson University
http://rise4fun com/Dafny SIGCSE 2013 OSU CSE 14 Dafny's int is considered unbounded, just like our NaturalNumber
[PDF] ENR - School of Environment and Natural Resources - The Ohio
The Ohio State University, School of Environment and Natural Resources Fall Semester 2016 A number of guest speakers will also facilitate these kinds of
[PDF] Environment and Natural Resources 2367 - School of Environment
the focus for group research term projects (Ohio State University Framework Plan , Sasaki Associates) At the end of the term, a select number of groups will earn
[PDF] Newsletter - Ferguson College of Agriculture - Oklahoma State
Soon after Dr Ansley arrives, Dr Omkar Joshi, our new natural resource ulty with the increased number of recruitment events hosted by OSU and the College
[PDF] Natural Resources Advising Guide OSU-Cascades - Oregon State
Perspectives (24) (No more than two Perspectives courses from same dept ) grade term course ___ __X__ _GEO ___ Physical Science (including lab) (4)
[PDF] Natural Resources OSU-Cascades
Natural Resources OSU-Cascades Perspectives (24) (No more than two Perspectives courses from same dept ) FW 318 Systematics of Mammals OSU
[PDF] Introducing Minorities to Natural Resource Career - CORE
The Ohio State University's School of Natural Resources developed and implemented a resident There was no difference in stress level factors between the
[PDF] otter creek little rock ar homes for sale
[PDF] ou aller en angleterre pour apprendre l'anglais
[PDF] où trouver votre numéro fiscal
[PDF] ouest france automobile 22
[PDF] ouest france automobile 44
[PDF] ouest france automobile 56
[PDF] ouest france automobile 85
[PDF] ouest france automobile occasion
[PDF] ouest france automobile rennes
[PDF] ouest france faits divers dol de bretagne
[PDF] ouest france faits divers la guerche de bretagne
[PDF] ouest france obseque vendee 85
[PDF] ouest france vendée obsèques challans
[PDF] ouest france vendée obsèques fontenay le comte
References
7 January 2019OSU CSE1
Primitive vs. Reference Types
•Java types are divided into two different categories: -The built-in types are called primitive types •Includes boolean, char, int, double -All other types are called reference types(or class types •Includes String, XMLTree, SimpleReader,SimpleWriter
, NaturalNumber, ...7 January 2019OSU CSE2
Primitive vs. Reference Types
•Java types are divided into two different categories: -The built-in types are called primitive types •Includes boolean, char, int, double -All other types are called reference types(or class types •Includes String, XMLTree, SimpleReader,SimpleWriter
, NaturalNumber, ...7 January 2019OSU CSE3
There is no limit on
the number of other user-defined types that can be developed.Categories of Types, v. 1
7 January 2019OSU CSE4
boolean char int double (plus 4 others)StringXMLTree
...SimpleReaderSimpleWriterNaturalNumber
Reference
TypesPrimitive
TypesPrimitive vs. Reference Variables
•A primitive variable is a variable of a primitive type -This term is used sparingly in practice, and is introduced here for parsimony to distinguish a variable of a primitive type from... •A reference variable is a variable of a reference type-A reference variable is fundamentally different from a primitive variable in ways that can dramatically impact how you reason about program behavior; beware!
7 January 2019OSU CSE5
Examples
7 January 2019OSU CSE6
true'y'133.14"Go"Examples
7 January 2019OSU CSE7
true'y'133.14"Go"Recall We Said Earlier...
7 January 2019OSU CSE8
This is a Stringvariable s
whose value is "Go", i.e., s = "Go" "Go" ... But Here's the "Real Picture"!7 January 2019OSU CSE9
"Go" ... But Here's the "Real Picture"!7 January 2019OSU CSE10
There is a Stringvariable
s , whose value is a referenceto an object whose value is "Go". "Go"References and Objects
7 January 2019OSU CSE11
This is the references.
"Go"References and Objects
7 January 2019OSU CSE12
This is the object s"points to"
or "refers to". "Go"Reference and Object Values
•A reference variable like smay be considered to have either of two values: -The reference value of sin these pictures is the memory address at which the object is stored -The object value ofsin these pictures is the mathematical model value of the object the reference spoints to, in this case "Go"7 January 2019OSU CSE13
Reference and Object Values
•A reference variable like smay be considered to have either of two values: -The reference value of sin these pictures is the memory address at which the object is stored -The object value ofsin these pictures is the mathematical model value of the object the reference spoints to, in this case "Go"7 January 2019OSU CSE14
Think of the reference value as
simply an "id" or "serial number" of some place in memory.Getting to the "Real Picture"
7 January 2019OSU CSE15
VariablesObjects
b c i d strue 22192021222324
Getting to the "Real Picture"
7 January 2019OSU CSE16
VariablesObjects
b c i d strue 22192021222324
This part of memory holds:
• valuesof primitive variables reference values ofreference
variablesGetting to the "Real Picture"
7 January 2019OSU CSE17
VariablesObjects
b c i d strue 22192021222324
This part of memory holds:
•object values ofreference variablesGetting to the "Real Picture"
7 January 2019OSU CSE18
VariablesObjects
b c i d strue 22192021222324
Each object in memory has a
unique memory address, or "id"; e.g., this one has id = 22.Getting to the "Real Picture"
7 January 2019OSU CSE19
VariablesObjects
b c i d strue 22192021222324
These numbers are the
"id"sof the objects.Getting to the "Real Picture"
7 January 2019OSU CSE20
VariablesObjects
b c i d strue 22192021222324
The reference value of a
reference variable is the memory address, or "id", of the object to which it refers.Getting to the "Real Picture"
7 January 2019OSU CSE21
VariablesObjects
b c i d strue 22192021222324
The reference value of a
reference variable , i.e., the address or "id" of the object it refers to, is immaterial; so, this situation ...Getting to the "Real Picture"
7 January 2019OSU CSE22
VariablesObjects
b c i d strue 23192021222324
... is indistinguishable in a program from this one. (Yet inC or C++, you may do
calculations with these addresses/" id"sas if they were numbers! How crazy is that?)Getting to the "Real Picture"
7 January 2019OSU CSE23
VariablesObjects
b c i d strue 2319 20 21
22
23
24
Similarly, it is immaterial to the
program exactly where each variable is located in memory.So We Can Simplify...
7 January 2019OSU CSE24
VariablesObjects
"Go"19 20 2122
23
24
true 'y' 13 3.14 23
So We Can Simplify...
7 January 2019OSU CSE25
VariablesObjects
"Go"19 20 2122
23
24
true 'y' 13 3.14 23
In our pictures, the types of
variables are as different shapes; all reference variables use an equilateral triangle.So We Can Simplify...
7 January 2019OSU CSE26
VariablesObjects
"Go"19 20 2122
23
24
true 'y' 13 3.14 23
Variables in the program
are in this part of memory.So We Can Simplify...
7 January 2019OSU CSE27
VariablesObjects
true 'y' 13 3.14 23"Go"
Objects in the program are
in this part of memory. 23So We Can Simplify...
7 January 2019OSU CSE28
VariablesObjects
true 'y' 13 3.14 "Go"In our pictures, the
connection between the reference value of a reference variable and its object value is as an arrow.Finally...
7 January 2019OSU CSE29
true 'y' 13 3.14 "Go"Our pictures allow us to
abstract away even the fact that there are two parts of memory.Notation
•We never care about writing down the reference value of a reference variable as a particular numerical value (though we draw a picture of it: an arrow out of a triangle) -So, if you see something like s = "Go"in a contract or a tracing table, it mustmean that the object value of sis the mathematical model value "Go"Notation
•In a tracing table, however, we might want to remindourselves there is a reference involved, so we might record the value of variable susing a right arrow instead of an equals sign, e.g., s -This means that sis a reference variable whose object value is "Go" -Or: srefers to an object with value "Go" -Whywould we do this? Coming up...7 January 2019OSU CSE31
The Assignment Operator
•The assignment operator =copiesthe value of the expression on the right-hand side into the variable on the left-hand side •For primitive types, "the value of" can mean only one thing •For reference types, it could mean "the referencevalue of" or "the object value of" -Which is it?7 January 2019OSU CSE32
Assignment for Primitive Types
•Consider: inti= k + 7; -First, the expression k + 7is evaluated; say k = 3, so the expression evaluates to 10 -Next, the value 10is copied into i, so after the above statement has finished executing, we have i= 10 •How does this happen?7 January 2019OSU CSE33
Step by Step: inti= k+ 7;
7 January 2019OSU CSE34
3We already have k, a
whose value is 3.Step by Step: inti= k + 7;
7 January 2019OSU CSE35
7The intliteral is an
whose value is 7. 3Step by Step: inti= k +7;
7 January 2019OSU CSE36
7The intaddition
operator +results in another anonymous primitive variable whose value is 10. 310Step by Step: inti= k + 7;
7 January 2019OSU CSE37
7The declaration of the
intvariable iresults in an 310Step by Step: inti=k + 7;
7 January 2019OSU CSE38
731010