• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. Data and Datatypes > Copying, Comparing, and Passing Data

3.6. Copying, Comparing, and Passing Data

There are three fundamental ways to manipulate data; we can copy it (e.g., assign the value of variable x to variable y), compare it (e.g., check whether x equals y), and pass it (e.g., supply a variable to a function as an argument). Primitive data values are copied, compared, and passed quite differently than composite data. When primitive data is copied to a variable, that variable gets its own unique and private copy of the data, stored separately in memory. Hence, the following lines of code cause the string "Dave" to be stored twice in memory, once in the memory location reserved for name1 and again in the location reserved for name2:

name1 = "Dave";
name2 = name1;


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint