wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

How Strings and Arrays are Alike

 

Strings are numeric arrays.  Not only are they numeric arrays, they are the simplest of numeric arrays since they only require one bit of storage per element.  

                                     

 

 

 

This is exactly the same as numeric arrays except for one slight modification:

We must know the base address of the array and where the string ends.  If we were to add an additional character at the end of the string, we could check to see if we have reached the end of the string.

Things to know about Strings  vs. Numeric Arrays

bullet

Strings are viewed slightly differently from numeric arrays because?              

Well, strings ARE numeric arrays of type character, but we are not necessarily interested in each offset from the base address. All we care about strings are where they begin (at the base address) and where they end (with the NULL (?\0?) character.

bullet

How are strings stored slightly differently in RAM than are numeric arrays?

The only difference is strings require 1 additional byte at the end of the array which is the NULL (?/0?) character

 

Quick links for additional help:

http://malun1.mala.bc.ca:8080/~wesselsd/csci160/notes/arrays.html

http://java.sun.com/docs/books/jni/html/objtypes.html