|| Ryerson University
School of Computer Science
CPS109 Computer Science 1
Class Notes Week 4
Fundamental Data Types
Math in Java
Strings as Objects
- An example of how Strings in Java are actually objects...its called Stringthing.
- Here is an illustration of object swapping and garbage collection as it applies
to the popular children's book "The Cat in the Hat". In this example we
create a class called Thingmaker that is the template
for making things. Thingdriver creates 2 things (thing1
and thing2 of course). The things get swapped and finally one is killed. If you are
a parent and you have read this book to your child don't let them see this code as
it might be disturbing.
- Here is an example of how to do some simple math in Java called Javamath.java..