Commit a6c598f2 by Joe Student

some minor mods

parent 9db188b4
...@@ -39,7 +39,7 @@ public class CastObjectsDriver { ...@@ -39,7 +39,7 @@ public class CastObjectsDriver {
//With reflection, we can see that we are NOT changing the object's type, it's still a Double, only now it's //With reflection, we can see that we are NOT changing the object's type, it's still a Double, only now it's
//being stored in a superlcass reference which restricts the of methods we can call on the reference //being stored in a superlcass reference which restricts the of methods we can call on the reference
//This is an automatic promotion, so the cast here is redundant //This is an automatic promotion, so the cast here is redundant
Number numMe = (Number) dubMe; Number numMe = dubMe;
System.out.println("A Number reference pointing to same Double object:"); System.out.println("A Number reference pointing to same Double object:");
System.out.println(numMe.getClass().toString()); System.out.println(numMe.getClass().toString());
//one of the methods we can call from the Number reference //one of the methods we can call from the Number reference
...@@ -60,7 +60,7 @@ public class CastObjectsDriver { ...@@ -60,7 +60,7 @@ public class CastObjectsDriver {
System.out.println("numMe and dubMe both point to the same object in memory space: " + (numMe == dubMe)); System.out.println("numMe and dubMe both point to the same object in memory space: " + (numMe == dubMe));
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
System.out.println(Double.valueOf((Double) comMe));
//Now let's cast this to an Object //Now let's cast this to an Object
//This is an automatic promotion, so the cast here is redundant //This is an automatic promotion, so the cast here is redundant
Object objMe = (Object) comMe; Object objMe = (Object) comMe;
......
...@@ -28,7 +28,7 @@ public class CastPrimitivesDriver { ...@@ -28,7 +28,7 @@ public class CastPrimitivesDriver {
//Let's promote this to an int which is a 32-bit signed integer ranging from -2^31 to 2^31 - 1 //Let's promote this to an int which is a 32-bit signed integer ranging from -2^31 to 2^31 - 1
int nMe = (int)sMe; int nMe = sMe;
//no problem, we don't really need all the precision, but memory is cheap, and the value stays the same. //no problem, we don't really need all the precision, but memory is cheap, and the value stays the same.
//when we copy the bits, we just put those bits into an 32-bit int like so -> //when we copy the bits, we just put those bits into an 32-bit int like so ->
//upcasting is automatic (no cast required) and looses no precision //upcasting is automatic (no cast required) and looses no precision
......
...@@ -7,7 +7,7 @@ public class RecursionDriver { ...@@ -7,7 +7,7 @@ public class RecursionDriver {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(myFactorialRec(5)); System.out.println(myFactorialRec(12));
System.out.println(myFactorialIter(5)); System.out.println(myFactorialIter(5));
testIsPalindrome("A man, a plan, a canal, Panama!"); testIsPalindrome("A man, a plan, a canal, Panama!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment