JAVA – note to self – Aliasing – When REPOINTS and when COPY happens

Below article is generated by Code @ very bottom of article:::
===============================================================

“C:\Program Files (x86)\Java\jdk1.7.0_21\bin\java” -Didea.launcher.port=7546 “-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.4\bin” -Dfile.encoding=UTF-8 -classpath “C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\rt.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.7.0_21\jre\lib\ext\zipfs.jar;C:\Users\kkhlebopros\IdeaProjects\stringtest\out\production\stringtest;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.4\lib\idea_rt.jar” com.intellij.rt.execution.application.AppMain stringtest

ALIASING
########
########

Here is the concept of aliasing. What things in java copy and what things in java make new references instead of a copy
Which ever one it is the effect is subtle (or large) and can cause bugs unless thought of carefully
The purpose of this is to make you comfortable with both aspects of aliasing where things copy and where things make new references

RULE OF THUMBS:
Primatives get copied
Objects (even wrapper types) point to new references – note Arrays are objects
Strings being the silly exception act like primatives in this case even though we know they are objects (because strings are immutable)

THE STEPS THAT I WILL BE TAKING TO EXAMINE ALIASING
1. Initialize 2 things (namely 1st thing and 2nd thing)
2. Give them different values
3. Set 2nd thing equal to 1st thing (I could of done 1st thing equal to 2nd thing, it doesnt matter – thats trivial)
4. Change the value of the 2nd thing (This is also trivial – we could change the value of the 1st thing)
5. Check if the change of the 2nd thing in step 2 changed the 1st thing

HOW TO INTERPRET RESULTS
At step 5 if the 2nd thing and the 1st thing are the same – meaning – if after setting 1st equal to 2nd thing and changing 2nd which also changes the 1st thing then:
* That’s a pointer pointing at a new memory location – not an actual copy
At step 5 if the 2nd thing and the 1st thing are different – meaning – if after setting 1st equal to 2nd thing and changing 2nd and the 1st thing remains unchanges:
* That’s a copy – a whole new memory location is made

ALIASING WITH STRINGS AND INTS
##############################
##############################

1 STRING
########
Declaring string A1 and B1 but setting to anything
A1 is set to ‘Cat’ & B1 is set to ‘Dog’
After setting – A1 is: Cat
After setting – B1 is: Dog
*** B1 set to A1 *** (Since String=String think of it like a primative=primative like an int=int, remember strings are Objects but behave like primatives sometimes because they are immutable)
After equal – A1 is: Cat
After equal – B1 is: Cat
B1 set to Human
After changing B1 – A1 is: Cat
After changing B1 – B1 is: Human
*** RESULT: Both different so its a COPY ***

2 STRING ARRAY – COPY ARRAY ALIASING
####################################
Init new strings array Array1 and Array2
Init new strings array – value of Array1:[Ljava.lang.String;@37fb1e
Init new strings array – value of Array2:[Ljava.lang.String;@1479feb
Init new strings array – value of Array1[1]:null
Init new strings array – value of Array2[1]:null
Setting Array[1] to ‘Cat’ and Array[2] to ‘Dog’
After value setting – value of Array1:[Ljava.lang.String;@37fb1e
After value setting – value of Array2:[Ljava.lang.String;@1479feb
After value setting – value of Array1[1]:Cat
After value setting – value of Array2[1]:Dog
***Setting Array1 equal to Array2*** (think object set equal to object)
After equal setting – value of Array1:[Ljava.lang.String;@37fb1e
After equal setting – value of Array2:[Ljava.lang.String;@37fb1e
After equal setting – value of Array1[1]:Cat
After equal setting – value of Array2[1]:Cat
Changing Array2[1] to ‘Man’
After changing Array2 – value of Array1:[Ljava.lang.String;@37fb1e
After changing Array2 – value of Array2:[Ljava.lang.String;@37fb1e
After changing Array2 – value of Array1[1]:Man
After changing Array2 – value of Array2[1]:Man
*** RESULT: Both same so its a REPOINT ***

3 STRING ARRAY – COPY ARRAY ENTRY ALIASING
##########################################
Init new strings array SArray1 and SArray2
Init new strings array – value of SArray1:[Ljava.lang.String;@1592174
Init new strings array – value of SArray2:[Ljava.lang.String;@a352a5
Init new strings array – value of SArray1[1]:null
Init new strings array – value of SArray2[1]:null
Setting SArray[1] to ‘Cat’ and SArray[2] to ‘Dog’
After value setting – value of SArray1:[Ljava.lang.String;@1592174
After value setting – value of SArray2:[Ljava.lang.String;@a352a5
After value setting – value of SArray1[1]:Cat
After value setting – value of SArray2[1]:Dog
*** Setting SArray1[1] equal to SArray2[1] *** (Think String = String like above)
After equal setting – value of SArray1:[Ljava.lang.String;@1592174
After equal setting – value of SArray2:[Ljava.lang.String;@a352a5
After equal setting – value of SArray1[1]:Cat
After equal setting – value of SArray2[1]:Cat
Changing SArray2[1] to ‘Man’
After changing SArray2 – value of SArray1:[Ljava.lang.String;@1592174
After changing SArray2 – value of SArray2:[Ljava.lang.String;@a352a5
After changing SArray2 – value of SArray1[1]:Cat
After changing SArray2 – value of SArray2[1]:Man
*** RESULT: Both different so its a COPY ***

4 INT
#####
PRE-COMMENT: Redirecting an array which are object – the result is a new reference (not a copy)
Init new int – value of i1: cant say yet – or would ERROR
Init new int – value of i2: cant say yet – or would ERROR
Setting i1 to 5 and i2 to 100
After setting – Value of i1:5
After setting – Value of i2:100
*** Setting i1 equal to i1 *** (think int=int, so primatives)
After equalizing – Value of i1:100
After equalizing – Value of i2:100
Changing i2 by adding 1 to i2 using ‘i2++;’ syntax
After changing i2 – Value of i1:100
After changing i2 – Value of i2:101
*** RESULT: Both different so its a COPY ***

5 ARRAY OF INTS (PRIMATIVE) – REASSIGNING AN ARRAY ENTRY
########################################################
PRE-COMMENT: Redirecting primative ints – the result is a copy (not a reference but a redirection)
Initializing iA1 and iA2
After init – Value of iA1:[I@1ea5671
After init – Value of iA2:[I@1d15445
Setting iA1 to 33 and iA2 to 500
After setting both – Value of iA1:[I@1ea5671
After setting both – Value of iA2:[I@1d15445
*** Setting iA1 equal to iA2 *** (think int=int, so primatives)
After equal – Value of iA1:[I@1ea5671
After equal – Value of iA2:[I@1d15445
Setting iA2[1]++
After changing iA2 – Value of iA1:[I@1ea5671
After changing iA2 – Value of iA2:[I@1d15445
After changing iA2 – Value of iA1[1]:500
After changing iA2 – Value of iA2[1]:501
*** RESULT: Both different so its a COPY ***

6 ARRAY OF INTS (PRIMATIVE) – REASSIGNING THE ARRAY
####################################################
PRE-COMMENT: Redirecting an array which are object – the result is a new reference (not a copy)
After initializing iAa1 and iAa2
After initializing – Value of iA1:[I@1f3aa07
After initializing – Value of iA2:[I@1fc2fb
Setting iAa1[1] to 320 and iAa2[1] to 520
After setting – Value of iA1:[I@1f3aa07
After setting – Value of iA2:[I@1fc2fb
*** Setting equal iAa1 and iAa2 *** (Think Array = Array so object = object)
After equal – Value of iA1:[I@1fc2fb
After equal – Value of iA2:[I@1fc2fb
Changing iAa2 by doing this iAa2++;
After changing iAa2 – Value of iAa1:[I@1fc2fb
After changing iAa2 – Value of iAa2:[I@1fc2fb
After changing iAa2 – Value of iA1[1]:521
After changing iAa2 – Value of iA2[1]:521
*** RESULT: Both same so its a REPOINT ***

7 INTEGER – WRAPPER
###################
Initializing iW1 and iW2
After initializing – Value of iW1: ERROR
After initializing – Value of iW2: ERROR
Setting iW1 and iW2 to 123 and 900 respectively
After setting – Value of iW1:123
After setting – Value of iW2:900
*** Setting iW1 equal to iW2 *** (Think Wrapper = Wrapper so object = object)
After equal – Value of iW1:900
After equal – Value of iW2:900
Changing iW2 by adding 1 to it with iW2++
After changing iW2 – Value of iW1:900
After changing iW2 – Value of iW2:901
*** RESULT: Both different so its a COPY ***

8 ARRAY OF INTEGERS (WRAPPER) – REASSIGNING AN ARRAY ENTRY
############################################################
Initializing iWa1 and iWa2
After initializing – Value of iWa1:[Ljava.lang.Integer;@139eeda
After initializing – Value of iWa2:[Ljava.lang.Integer;@704baa
After initializing – Value of iWa1[1]:null
After initializing – Value of iWa2[1]:null
Setting iWa1[1] and iWa2[1] to 50 and 80 respectively
After setting – Value of iWa1:[Ljava.lang.Integer;@139eeda
After setting – Value of iWa2:[Ljava.lang.Integer;@704baa
After setting – Value of iWa1[1]:50
After setting – Value of iWa2[1]:80
*** Setting iWa1[1] equal to iWa2[1] *** (Think Wrapper = Wrapper so object = object)
After equal – Value of iW1:[Ljava.lang.Integer;@139eeda
After equal – Value of iW2:[Ljava.lang.Integer;@704baa
After equal – Value of iW1[i]:80
After equal – Value of iW2[i]:80
Changing iWa2[1] by adding 1 to it with iWa2[1]++
After changing iWa2 – Value of iWa1:[Ljava.lang.Integer;@139eeda
After changing iWa2 – Value of iWa2:[Ljava.lang.Integer;@704baa
After changing iWa2 – Value of iWa1[i]:80
After changing iWa2 – Value of iWa2[i]:81
*** RESULT: Both different so its a COPY ***

9 ARRAY OF INTEGERS (WRAPPER) – REASSIGNING THE ARRAY
#######################################################
Initializing iWWa1 and iWWa2
After init – Value of iWWa1:[Ljava.lang.Integer;@77a7f9
After init – Value of iWWa2:[Ljava.lang.Integer;@1b4fad5
After init – Value of iWWa1[i]:null
After init – Value of iWWa2[i]:null
Setting iWWa1[1] and iWWa2[1] to 510 and 810 respectively
After setting – Value of iWWa1:[Ljava.lang.Integer;@77a7f9
After setting – Value of iWWa2:[Ljava.lang.Integer;@1b4fad5
After setting – Value of iWWa1[i]:510
After setting – Value of iWWa2[i]:810
*** Setting iWWa1 equal to iWWa2 *** (Think Array = Array so object = object)
After equal – Value of iWWa1:[Ljava.lang.Integer;@1b4fad5
After equal – Value of iWWa2:[Ljava.lang.Integer;@1b4fad5
After equal – Value of iWWa1[i]:810
After equal – Value of iWWa2[i]:810
Changing iWWa2[1] by adding 1 to it with iWWa2[1]++
After changing iWWa2 – Value of iWWa1:[Ljava.lang.Integer;@1b4fad5
After changing iWWa2 – Value of iWWa2:[Ljava.lang.Integer;@1b4fad5
After changing iWWa2 – Value of iWWa1[i]:811
After changing iWWa2 – Value of iWWa2[i]:811
*** RESULT: Both same so its a REPOINT ***

OBJECT AND ALIASING
###################
###################
Making class Pepsi with, int oz = 12, and, String taste = ‘taste’
Also going to show the effect of ++i and i++ during the step where we change the 2nd thing

10 OBJECT ALIASING – ON INT
############################
After init ‘Pepsi pepsi1’ – pepsi1.oz: ERROR
After init ‘Pepsi pepsi2’ – pepsi2.oz: ERROR
After setting – pepsi1.oz: 12
After setting – pepsi2.oz: 12
*** Going to set em equal like this pepsi2 = pepsi1; *** (Think Object = Object)
After equal – pepsi1.oz: 12
After equal – pepsi2.oz: 12
pepsi2.oz++ value changed after this line:12
++pepsi2.oz value changed before this line:14
After Changing pepsi2.oz by 2
End result – pepsi1.oz: 14
End result – pepsi2.oz: 14
*** RESULT: Both same so its a REPOINT ***

11 ARRAY OF OBJECTS – THE FULL ARRAY ALIASING – ON INT
######################################################
PRE-COMMENT: Since the subject in mind is an object (array are objects) – a setting will change reference and it will not a do a copy.
After init – pepsis1[1].oz: ERROR
After init – pepsis2[1].oz: ERROR
After setting – pepsis1[1].oz: 12
After setting – pepsis2[1].oz: 12
*** Going to set em equal like this pepsis2 = pepsis1; *** (Think Array = Array so Object = Object)
After Equal – pepsis1[1].oz: 12
After Equal – pepsis2[1].oz: 12
pepsis2[1].oz++ value changed after this line:12
++pepsis2[1].oz value changed before this line:14
After Changing pepsis2[1].oz by 2
End result after change – pepsis1[1].oz: 14
End result after change – pepsis2[1].oz: 14
*** RESULT: Both same so its a REPOINT ***

12 ARRAY OF OBJECTS – AN OBJECT ALIASING – ON INT
#################################################
PRE-COMMENT: Since the subject in mind is an object then it will act like an object – a setting will change reference and it will not a do a copy.
PRE-COMMENT: Since above case was also an object the effect will be the same.
After init – pepsisa1[1].oz: ERROR
After init – pepsisa2[1].oz: ERROR
After setting – pepsisa1[1].oz: 12
After setting – pepsisa2[1].oz: 12
*** Going to set em equal like this pepsisa2[1] = pepsisa1[1]; *** (Think Object = Object, why object because pepsisa#[X] is an object)
After equal – pepsisa1[1].oz: 12
After equal – pepsisa2[1].oz: 12
pepsisa2[1].oz++ value changed after this line:12
++pepsisa2[1].oz value changed before this line:14
After Changing pepsisa2[1].oz by 2
End Result – pepsisa1[1].oz: 14
End Result – pepsisa2[1].oz: 14
*** RESULT: Both same so its a REPOINT ***

13 ARRAY OF OBJECTS – AN OBJECTS VALUE ALIASING – ON INT
########################################################
PRE-COMMENT: Since the subject in mind is a value in this case an int, it will act like the int. So the primatives get copied.
After Init – pepsisaa1[1].oz: ERROR
After Init – pepsisaa2[1].oz: ERROR
After Setting – pepsisaa1[1].oz: 12
After Setting – pepsisaa2[1].oz: 12
*** Going to set em equal like this pepsisaa2[1].oz = pepsisaa1[1].oz; *** (Think String = String, which is an object=object, but since strings are unique its more like primative=primative like in above string cases)
After Equal – pepsisaa1[1].oz: 12
After Equal – pepsisaa2[1].oz: 12
pepsisaa2[1].oz++ value changed after this line:12
++pepsisaa2[1].oz value changed before this line:14
After Changing pepsisaa2[1].oz by 2
End Result – pepsisaa1[1].oz: 12
End Result – pepsisaa2[1].oz: 14
*** RESULT: Both different so its a COPY ***

14 OBJECT ALIASING – ON STRING
############################
After init ‘Pepsi Spepsi1’ – Spepsi1.taste: ERROR
After init ‘Pepsi Spepsi2’ – Spepsi2.taste: ERROR
After setting – Spepsi1.taste: The Best
After setting – Spepsi2.taste: The Best
*** Going to set em equal like this Spepsi2 = Spepsi1; *** (Think Object = Object)
After equal – Spepsi1.taste: The Best
After equal – Spepsi2.taste: The Best
After Changing taste to OK of Spepsi2.taste
End result – Spepsi1.taste: OK
End result – Spepsi2.taste: OK
*** RESULT: Both same so its a REPOINT ***

15 ARRAY OF OBJECTS – THE FULL ARRAY ALIASING – ON STRING
######################################################
PRE-COMMENT: Since the subject in mind is an object (array are objects) – a setting will change reference and it will not a do a copy.
After init – Spepsis1[1].taste: ERROR
After init – Spepsis2[1].taste: ERROR
After setting – Spepsis1[1].taste: The Best
After setting – Spepsis2[1].taste: The Best
*** Going to set em equal like this Spepsis2 = Spepsis1; *** (Think Array = Array so Object = Object)
After Equal – Spepsis1[1].taste: The Best
After Equal – Spepsis2[1].taste: The Best
After Changing taste to OK of Spepsis2[1].taste
End result after change – Spepsis1[1].taste: OK
End result after change – Spepsis2[1].taste: OK
*** RESULT: Both same so its a REPOINT ***

16 ARRAY OF OBJECTS – AN OBJECT ALIASING – ON STRING
#################################################
PRE-COMMENT: Since the subject in mind is an object then it will act like an object – a setting will change reference and it will not a do a copy.
PRE-COMMENT: Since above case was also an object the effect will be the same.
After init – Spepsisa1[1].taste: ERROR
After init – Spepsisa2[1].taste: ERROR
After setting – Spepsisa1[1].taste: The Best
After setting – Spepsisa2[1].taste: The Best
*** Going to set em equal like this Spepsisa2[1] = Spepsisa1[1]; *** (Think Object = Object, why object because pepsisa#[X] is an object)
After equal – Spepsisa1[1].taste: The Best
After equal – Spepsisa2[1].taste: The Best
After Changing taste to OK of Spepsisa2[1].taste
End Result – Spepsisa1[1].taste: OK
End Result – Spepsisa2[1].taste: OK
*** RESULT: Both same so its a REPOINT ***

17 ARRAY OF OBJECTS – AN OBJECTS VALUE ALIASING – ON STRING
########################################################
PRE-COMMENT: Since the subject in mind is a value in this case an int, it will act like the int. So the primatives get copied.
After Init – Spepsisaa1[1].taste: ERROR
After Init – Spepsisaa2[1].taste: ERROR
After Setting – Spepsisaa1[1].taste: The Best
After Setting – Spepsisaa2[1].taste: The Best
*** Going to set em equal like this Spepsisaa2[1].taste = Spepsisaa1[1].taste; *** (Think int = int)
After Equal – Spepsisaa1[1].taste: The Best
After Equal – Spepsisaa2[1].taste: The Best
After Changing taste to OK of Spepsisaa2[1].taste
End Result – Spepsisaa1[1].taste: The Best
End Result – Spepsisaa2[1].taste: OK
*** RESULT: Both different so its a COPY ***

Process finished with exit code 0

######################################################################################################################
######################################################################################################################
######################################################################################################################
######################################################################################################################
######################################################################################################################

/**
 * Aliasing tests
 * User: infotinks
 * Date: 9/5/13
 * Time: 1:10 PM
 */
public class stringtest {

    public static void main(String[] args){
        // INTRO
        System.out.println("ALIASING");
        System.out.println("########");
        System.out.println("########");
        System.out.println("");
        System.out.println("Here is the concept of aliasing. What things in java copy and what things in java make new references instead of a copy");
        System.out.println("Which ever one it is the effect is subtle (or large) and can cause bugs unless thought of carefully");
        System.out.println("The purpose of this is to make you comfortable with both aspects of aliasing where things copy and where things make new references");
        System.out.println("");
        System.out.println("RULE OF THUMBS:");
        System.out.println("Primatives get copied");
        System.out.println("Objects (even wrapper types) point to new references - note Arrays are objects");
        System.out.println("Strings being the silly exception act like primatives in this case even though we know they are objects (because strings are immutable)");
        System.out.println("");
        System.out.println("THE STEPS THAT I WILL BE TAKING TO EXAMINE ALIASING");
        System.out.println("1. Initialize 2 things (namely 1st thing and 2nd thing)");
        System.out.println("2. Give them different values");
        System.out.println("3. Set 2nd thing equal to 1st thing (I could of done 1st thing equal to 2nd thing, it doesnt matter - thats trivial)");
        System.out.println("4. Change the value of the 2nd thing (This is also trivial - we could change the value of the 1st thing)");
        System.out.println("5. Check if the change of the 2nd thing in step 2 changed the 1st thing");
        System.out.println("");
        System.out.println("HOW TO INTERPRET RESULTS");
        System.out.println("At step 5 if the 2nd thing and the 1st thing are the same - meaning - if after setting 1st equal to 2nd thing and changing 2nd which also changes the 1st thing then:");
        System.out.println("* That's a pointer pointing at a new memory location - not an actual copy");
        System.out.println("At step 5 if the 2nd thing and the 1st thing are different - meaning - if after setting 1st equal to 2nd thing and changing 2nd and the 1st thing remains unchanges:");
        System.out.println("* That's a copy - a whole new memory location is made");
        System.out.println("");
        // WE BEGIN
        System.out.println("ALIASING WITH STRINGS AND INTS");
        System.out.println("##############################");
        System.out.println("##############################");
        System.out.println("");
        System.out.println("1 STRING");
        System.out.println("########");
        System.out.println("Declaring string A1 and B1 but setting to anything");
        String A1;
        String B1;
        System.out.println("A1 is set to 'Cat' & B1 is set to 'Dog'");
        A1 = "Cat";
        B1 = "Dog";
        System.out.println("After setting - A1 is: "+ A1);
        System.out.println("After setting - B1 is: "+ B1);
        System.out.println("*** B1 set to A1 *** (Since String=String think of it like a primative=primative like an int=int, remember strings are Objects but behave like primatives sometimes because they are immutable)");
        B1 = A1;
        System.out.println("After equal - A1 is: "+ A1);
        System.out.println("After equal - B1 is: "+ B1);
        System.out.println("B1 set to Human");
        B1 = "Human";
        System.out.println("After changing B1 - A1 is: "+A1);
        System.out.println("After changing B1 - B1 is: "+B1);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("2 STRING ARRAY - COPY ARRAY ALIASING");
        System.out.println("####################################");
        System.out.println("Init new strings array Array1 and Array2");
        String[] Array1 = new String[10];
        String[] Array2 = new String[10];
        System.out.println("Init new strings array - value of Array1:" + Array1);
        System.out.println("Init new strings array - value of Array2:" + Array2);
        System.out.println("Init new strings array - value of Array1[1]:"+ Array1[1]);
        System.out.println("Init new strings array - value of Array2[1]:"+ Array2[1]);
        System.out.println("Setting Array[1] to 'Cat' and Array[2] to 'Dog'");
        Array1[1] = "Cat";
        Array2[1] = "Dog";
        System.out.println("After value setting - value of Array1:" + Array1);
        System.out.println("After value setting - value of Array2:" + Array2);
        System.out.println("After value setting - value of Array1[1]:"+ Array1[1]);
        System.out.println("After value setting - value of Array2[1]:"+ Array2[1]);
        System.out.println("***Setting Array1 equal to Array2*** (think object set equal to object)");
        Array2 = Array1;
        System.out.println("After equal setting - value of Array1:" + Array1);
        System.out.println("After equal setting - value of Array2:" + Array2);
        System.out.println("After equal setting - value of Array1[1]:"+ Array1[1]);
        System.out.println("After equal setting - value of Array2[1]:"+ Array2[1]);
        System.out.println("Changing Array2[1] to 'Man'");
        Array2[1] = "Man";
        System.out.println("After changing Array2 - value of Array1:" + Array1);
        System.out.println("After changing Array2 - value of Array2:" + Array2);
        System.out.println("After changing Array2 - value of Array1[1]:"+ Array1[1]);
        System.out.println("After changing Array2 - value of Array2[1]:"+ Array2[1]);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("3 STRING ARRAY - COPY ARRAY ENTRY ALIASING");
        System.out.println("##########################################");
        System.out.println("Init new strings array SArray1 and SArray2");
        String[] SArray1 = new String[10];
        String[] SArray2 = new String[10];
        System.out.println("Init new strings array - value of SArray1:" + SArray1);
        System.out.println("Init new strings array - value of SArray2:" + SArray2);
        System.out.println("Init new strings array - value of SArray1[1]:"+ SArray1[1]);
        System.out.println("Init new strings array - value of SArray2[1]:"+ SArray2[1]);
        System.out.println("Setting SArray[1] to 'Cat' and SArray[2] to 'Dog'");
        SArray1[1] = "Cat";
        SArray2[1] = "Dog";
        System.out.println("After value setting - value of SArray1:" + SArray1);
        System.out.println("After value setting - value of SArray2:" + SArray2);
        System.out.println("After value setting - value of SArray1[1]:"+ SArray1[1]);
        System.out.println("After value setting - value of SArray2[1]:"+ SArray2[1]);
        System.out.println("*** Setting SArray1[1] equal to SArray2[1] *** (Think String = String like above)");
        SArray2[1] = SArray1[1];
        System.out.println("After equal setting - value of SArray1:" + SArray1);
        System.out.println("After equal setting - value of SArray2:" + SArray2);
        System.out.println("After equal setting - value of SArray1[1]:"+ SArray1[1]);
        System.out.println("After equal setting - value of SArray2[1]:"+ SArray2[1]);
        System.out.println("Changing SArray2[1] to 'Man'");
        SArray2[1] = "Man";
        System.out.println("After changing SArray2 - value of SArray1:" + SArray1);
        System.out.println("After changing SArray2 - value of SArray2:" + SArray2);
        System.out.println("After changing SArray2 - value of SArray1[1]:"+ SArray1[1]);
        System.out.println("After changing SArray2 - value of SArray2[1]:"+ SArray2[1]);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("4 INT");
        System.out.println("#####");
        System.out.println("PRE-COMMENT: Redirecting an array which are object - the result is a new reference (not a copy)");
        int i1;
        int i2;
        System.out.println("Init new int - value of i1: cant say yet - or would ERROR");
        System.out.println("Init new int - value of i2: cant say yet - or would ERROR");
        System.out.println("Setting i1 to 5 and i2 to 100");
        i1 = 5;
        i2 = 100;
        System.out.println("After setting - Value of i1:" + i1);
        System.out.println("After setting - Value of i2:" + i2);
        System.out.println("*** Setting i1 equal to i1 *** (think int=int, so primatives)");
        i1 = i2;
        System.out.println("After equalizing - Value of i1:" + i1);
        System.out.println("After equalizing - Value of i2:" + i2);
        System.out.println("Changing i2 by adding 1 to i2 using 'i2++;' syntax");
        i2++;
        System.out.println("After changing i2 - Value of i1:" + i1);
        System.out.println("After changing i2 - Value of i2:" + i2);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("5 ARRAY OF INTS (PRIMATIVE) - REASSIGNING AN ARRAY ENTRY");
        System.out.println("########################################################");
        System.out.println("PRE-COMMENT: Redirecting primative ints - the result is a copy (not a reference but a redirection)");
        System.out.println("Initializing iA1 and iA2");
        int[] iA1 = new int[10];
        int[] iA2 = new int[10];
        System.out.println("After init - Value of iA1:" + iA1);
        System.out.println("After init - Value of iA2:" + iA2);
        System.out.println("Setting iA1 to 33 and iA2 to 500");
        iA1[1] = 33;
        iA2[1] = 500;
        System.out.println("After setting both - Value of iA1:" + iA1);
        System.out.println("After setting both - Value of iA2:" + iA2);
        System.out.println("*** Setting iA1 equal to iA2 *** (think int=int, so primatives)");
        iA1[1] = iA2[1];
        System.out.println("After equal - Value of iA1:" + iA1);
        System.out.println("After equal - Value of iA2:" + iA2);
        System.out.println("Setting iA2[1]++");
        iA2[1]++;
        System.out.println("After changing iA2 - Value of iA1:" + iA1);
        System.out.println("After changing iA2 - Value of iA2:" + iA2);
        System.out.println("After changing iA2 - Value of iA1[1]:" + iA1[1]);
        System.out.println("After changing iA2 - Value of iA2[1]:" + iA2[1]);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("6 ARRAY OF INTS (PRIMATIVE) - REASSIGNING THE ARRAY");
        System.out.println("####################################################");
        System.out.println("PRE-COMMENT: Redirecting an array which are object - the result is a new reference (not a copy)");
        System.out.println("After initializing iAa1 and iAa2");
        int[] iAa1 = new int[10];
        int[] iAa2 = new int[10];
        System.out.println("After initializing - Value of iA1:" + iAa1);
        System.out.println("After initializing - Value of iA2:" + iAa2);
        System.out.println("Setting iAa1[1] to 320 and iAa2[1] to 520");
        iAa1[1] = 320;
        iAa2[1] = 520;
        System.out.println("After setting - Value of iA1:" + iAa1);
        System.out.println("After setting - Value of iA2:" + iAa2);
        System.out.println("*** Setting equal iAa1 and iAa2 *** (Think Array = Array so object = object)");
        iAa1 = iAa2;
        System.out.println("After equal - Value of iA1:" + iAa1);
        System.out.println("After equal - Value of iA2:" + iAa2);
        System.out.println("Changing iAa2 by doing this iAa2++;");
        iAa2[1]++;
        System.out.println("After changing iAa2 - Value of iAa1:" + iAa1);
        System.out.println("After changing iAa2 - Value of iAa2:" + iAa2);
        System.out.println("After changing iAa2 - Value of iA1[1]:" + iAa1[1]);
        System.out.println("After changing iAa2 - Value of iA2[1]:" + iAa2[1]);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("7 INTEGER - WRAPPER");
        System.out.println("###################");
        System.out.println("Initializing iW1 and iW2");
        Integer iW1;
        Integer iW2;
        System.out.println("After initializing - Value of iW1: ERROR");
        System.out.println("After initializing - Value of iW2: ERROR");
        System.out.println("Setting iW1 and iW2 to 123 and 900 respectively");
        iW1 = 123;
        iW2 = 900;
        System.out.println("After setting - Value of iW1:" + iW1);
        System.out.println("After setting - Value of iW2:" + iW2);
        System.out.println("*** Setting iW1 equal to iW2 *** (Think Wrapper = Wrapper so object = object)");
        iW1 = iW2;
        System.out.println("After equal - Value of iW1:" + iW1);
        System.out.println("After equal - Value of iW2:" + iW2);
        System.out.println("Changing iW2 by adding 1 to it with iW2++");
        iW2++;
        System.out.println("After changing iW2 - Value of iW1:" + iW1);
        System.out.println("After changing iW2 - Value of iW2:" + iW2);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("8 ARRAY OF INTEGERS (WRAPPER) - REASSIGNING AN ARRAY ENTRY");
        System.out.println("############################################################");
        System.out.println("Initializing iWa1 and iWa2");
        Integer[] iWa1 = new Integer[10];
        Integer[] iWa2 = new Integer[10];
        System.out.println("After initializing - Value of iWa1:" + iWa1);
        System.out.println("After initializing - Value of iWa2:" + iWa2);
        System.out.println("After initializing - Value of iWa1[1]:" + iWa1[1]);
        System.out.println("After initializing - Value of iWa2[1]:" + iWa2[1]);
        System.out.println("Setting iWa1[1] and iWa2[1] to 50 and 80 respectively");
        iWa1[1] = 50;
        iWa2[1] = 80;
        System.out.println("After setting - Value of iWa1:" + iWa1);
        System.out.println("After setting - Value of iWa2:" + iWa2);
        System.out.println("After setting - Value of iWa1[1]:" + iWa1[1]);
        System.out.println("After setting - Value of iWa2[1]:" + iWa2[1]);
        System.out.println("*** Setting iWa1[1] equal to iWa2[1] *** (Think Wrapper = Wrapper so object = object)");
        iWa1[1] = iWa2[1];
        System.out.println("After equal - Value of iW1:" +  iWa1);
        System.out.println("After equal - Value of iW2:" +  iWa2);
        System.out.println("After equal - Value of iW1[i]:" +  iWa1[1]);
        System.out.println("After equal - Value of iW2[i]:" +  iWa2[1]);
        System.out.println("Changing iWa2[1] by adding 1 to it with iWa2[1]++");
        iWa2[1]++;
        System.out.println("After changing iWa2 - Value of iWa1:" + iWa1);
        System.out.println("After changing iWa2 - Value of iWa2:" + iWa2);
        System.out.println("After changing iWa2 - Value of iWa1[i]:" + iWa1[1]);
        System.out.println("After changing iWa2 - Value of iWa2[i]:" + iWa2[1]);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        System.out.println("9 ARRAY OF INTEGERS (WRAPPER) - REASSIGNING THE ARRAY");
        System.out.println("#######################################################");
        System.out.println("Initializing iWWa1 and iWWa2");
        Integer[] iWWa1 = new Integer[10];
        Integer[] iWWa2 = new Integer[10];
        System.out.println("After init - Value of iWWa1:" + iWWa1);
        System.out.println("After init - Value of iWWa2:" + iWWa2);
        System.out.println("After init - Value of iWWa1[i]:" + iWWa1[1]);
        System.out.println("After init - Value of iWWa2[i]:" + iWWa2[1]);
        System.out.println("Setting iWWa1[1] and iWWa2[1] to 510 and 810 respectively");
        iWWa1[1] = 510;
        iWWa2[1] = 810;
        System.out.println("After setting - Value of iWWa1:" + iWWa1);
        System.out.println("After setting - Value of iWWa2:" + iWWa2);
        System.out.println("After setting - Value of iWWa1[i]:" + iWWa1[1]);
        System.out.println("After setting - Value of iWWa2[i]:" + iWWa2[1]);
        System.out.println("*** Setting iWWa1 equal to iWWa2 *** (Think Array = Array so object = object)");
        iWWa1 = iWWa2;
        System.out.println("After equal - Value of iWWa1:" + iWWa1);
        System.out.println("After equal - Value of iWWa2:" + iWWa2);
        System.out.println("After equal - Value of iWWa1[i]:" + iWWa1[1]);
        System.out.println("After equal - Value of iWWa2[i]:" + iWWa2[1]);
        System.out.println("Changing iWWa2[1] by adding 1 to it with iWWa2[1]++");
        iWWa2[1]++;
        System.out.println("After changing iWWa2 - Value of iWWa1:" + iWWa1);
        System.out.println("After changing iWWa2 - Value of iWWa2:" + iWWa2);
        System.out.println("After changing iWWa2 - Value of iWWa1[i]:" + iWWa1[1]);
        System.out.println("After changing iWWa2 - Value of iWWa2[i]:" + iWWa2[1]);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("OBJECT AND ALIASING");
        System.out.println("###################");
        System.out.println("###################");
        System.out.println("Making class Pepsi with, int oz = 12, and, String taste = 'taste'");
        System.out.println("Also going to show the effect of ++i and i++ during the step where we change the 2nd thing");
        System.out.println("");
        // INNER CLASS - doesnt matter if inner or outter still the same effect with aliasing
        class Pepsi {
            int oz = 12;
            String taste = "The Best";
        }
        // END OF INNER CLASS
        // WITH INTS
        // WITH INTS
        // WITH INTS
        System.out.println("10 OBJECT ALIASING - ON INT");
        System.out.println("############################");
        Pepsi pepsi1;
        Pepsi pepsi2;
        System.out.println("After init 'Pepsi pepsi1' - pepsi1.oz: ERROR");
        System.out.println("After init 'Pepsi pepsi2' - pepsi2.oz: ERROR");
        pepsi1 = new Pepsi();
        pepsi2 = new Pepsi();
        System.out.println("After setting - pepsi1.oz: " + pepsi1.oz);
        System.out.println("After setting - pepsi2.oz: " + pepsi2.oz);
        System.out.println("*** Going to set em equal like this pepsi2 = pepsi1; *** (Think Object = Object)");
        pepsi2 = pepsi1;
        System.out.println("After equal - pepsi1.oz: " + pepsi1.oz);
        System.out.println("After equal - pepsi2.oz: " + pepsi2.oz);
        System.out.println("pepsi2.oz++ value changed after this line:" + pepsi2.oz++);
        System.out.println("++pepsi2.oz value changed before this line:" + ++pepsi2.oz);
        System.out.println("After Changing pepsi2.oz by 2");
        System.out.println("End result - pepsi1.oz: " + pepsi1.oz);
        System.out.println("End result - pepsi2.oz: " + pepsi2.oz);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("11 ARRAY OF OBJECTS - THE FULL ARRAY ALIASING - ON INT");
        System.out.println("######################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is an object (array are objects) - a setting will change reference and it will not a do a copy.");
        Pepsi[] pepsis1 = new Pepsi[10];
        Pepsi[] pepsis2 = new Pepsi[10];
        System.out.println("After init - pepsis1[1].oz: ERROR");
        System.out.println("After init - pepsis2[1].oz: ERROR");
        pepsis1[1] = new Pepsi();
        pepsis2[1] = new Pepsi();
        System.out.println("After setting - pepsis1[1].oz: " + pepsis1[1].oz);
        System.out.println("After setting - pepsis2[1].oz: " + pepsis2[1].oz);
        System.out.println("*** Going to set em equal like this pepsis2 = pepsis1; *** (Think Array = Array so Object = Object)");
        pepsis2 = pepsis1;
        System.out.println("After Equal - pepsis1[1].oz: " + pepsis1[1].oz);
        System.out.println("After Equal - pepsis2[1].oz: " + pepsis2[1].oz);
        System.out.println("pepsis2[1].oz++ value changed after this line:" + pepsis2[1].oz++);
        System.out.println("++pepsis2[1].oz value changed before this line:" + ++pepsis2[1].oz);
        System.out.println("After Changing pepsis2[1].oz by 2");
        System.out.println("End result after change - pepsis1[1].oz: " + pepsis1[1].oz);
        System.out.println("End result after change - pepsis2[1].oz: " + pepsis2[1].oz);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("12 ARRAY OF OBJECTS - AN OBJECT ALIASING - ON INT");
        System.out.println("#################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is an object then it will act like an object - a setting will change reference and it will not a do a copy.");
        System.out.println("PRE-COMMENT: Since above case was also an object the effect will be the same.");
        Pepsi[] pepsisa1 = new Pepsi[10];
        Pepsi[] pepsisa2 = new Pepsi[10];
        System.out.println("After init - pepsisa1[1].oz: ERROR");
        System.out.println("After init - pepsisa2[1].oz: ERROR");
        pepsisa1[1] = new Pepsi();
        pepsisa2[1] = new Pepsi();
        System.out.println("After setting - pepsisa1[1].oz: " + pepsisa1[1].oz);
        System.out.println("After setting - pepsisa2[1].oz: " + pepsisa2[1].oz);
        System.out.println("*** Going to set em equal like this  pepsisa2[1] = pepsisa1[1]; *** (Think Object = Object, why object because pepsisa#[X] is an object)");
        pepsisa2[1] = pepsisa1[1];
        System.out.println("After equal - pepsisa1[1].oz: " + pepsisa1[1].oz);
        System.out.println("After equal - pepsisa2[1].oz: " + pepsisa2[1].oz);
        System.out.println("pepsisa2[1].oz++ value changed after this line:" + pepsisa2[1].oz++);
        System.out.println("++pepsisa2[1].oz value changed before this line:" + ++pepsisa2[1].oz);
        System.out.println("After Changing pepsisa2[1].oz by 2");
        System.out.println("End Result - pepsisa1[1].oz: " + pepsisa1[1].oz);
        System.out.println("End Result - pepsisa2[1].oz: " + pepsisa2[1].oz);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("13 ARRAY OF OBJECTS - AN OBJECTS VALUE ALIASING - ON INT");
        System.out.println("########################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is a value in this case an int, it will act like the int. So the primatives get copied.");
        Pepsi[] pepsisaa1 = new Pepsi[10];
        Pepsi[] pepsisaa2 = new Pepsi[10];
        System.out.println("After Init - pepsisaa1[1].oz: ERROR");
        System.out.println("After Init - pepsisaa2[1].oz: ERROR");
        pepsisaa1[1] = new Pepsi();
        pepsisaa2[1] = new Pepsi();
        System.out.println("After Setting - pepsisaa1[1].oz: " + pepsisaa1[1].oz);
        System.out.println("After Setting - pepsisaa2[1].oz: " + pepsisaa2[1].oz);
        System.out.println("*** Going to set em equal like this pepsisaa2[1].oz = pepsisaa1[1].oz; *** (Think String = String, which is an object=object, but since strings are unique its more like primative=primative like in above string cases)");
        pepsisaa2[1].oz = pepsisaa1[1].oz;
        System.out.println("After Equal - pepsisaa1[1].oz: " + pepsisaa1[1].oz);
        System.out.println("After Equal - pepsisaa2[1].oz: " + pepsisaa2[1].oz);
        System.out.println("pepsisaa2[1].oz++ value changed after this line:" + pepsisaa2[1].oz++);
        System.out.println("++pepsisaa2[1].oz value changed before this line:" + ++pepsisaa2[1].oz);
        System.out.println("After Changing pepsisaa2[1].oz by 2");
        System.out.println("End Result - pepsisaa1[1].oz: " + pepsisaa1[1].oz);
        System.out.println("End Result - pepsisaa2[1].oz: " + pepsisaa2[1].oz);
        System.out.println("*** RESULT: Both different so its a COPY ***");
        System.out.println("");
        // WITH STRINGS
        // WITH STRINGS
        // WITH STRINGS
        System.out.println("14 OBJECT ALIASING - ON STRING");
        System.out.println("############################");
        Pepsi Spepsi1;
        Pepsi Spepsi2;
        System.out.println("After init 'Pepsi Spepsi1' - Spepsi1.taste: ERROR");
        System.out.println("After init 'Pepsi Spepsi2' - Spepsi2.taste: ERROR");
        Spepsi1 = new Pepsi();
        Spepsi2 = new Pepsi();
        System.out.println("After setting - Spepsi1.taste: " + Spepsi1.taste);
        System.out.println("After setting - Spepsi2.taste: " + Spepsi2.taste);
        System.out.println("*** Going to set em equal like this Spepsi2 = Spepsi1; *** (Think Object = Object)");
        Spepsi2 = Spepsi1;
        System.out.println("After equal - Spepsi1.taste: " + Spepsi1.taste);
        System.out.println("After equal - Spepsi2.taste: " + Spepsi2.taste);
        Spepsi2.taste = "OK";
        System.out.println("After Changing taste to OK of Spepsi2.taste");
        System.out.println("End result - Spepsi1.taste: " + Spepsi1.taste);
        System.out.println("End result - Spepsi2.taste: " + Spepsi2.taste);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("15 ARRAY OF OBJECTS - THE FULL ARRAY ALIASING - ON STRING");
        System.out.println("######################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is an object (array are objects) - a setting will change reference and it will not a do a copy.");
        Pepsi[] Spepsis1 = new Pepsi[10];
        Pepsi[] Spepsis2 = new Pepsi[10];
        System.out.println("After init - Spepsis1[1].taste: ERROR");
        System.out.println("After init - Spepsis2[1].taste: ERROR");
        Spepsis1[1] = new Pepsi();
        Spepsis2[1] = new Pepsi();
        System.out.println("After setting - Spepsis1[1].taste: " + Spepsis1[1].taste);
        System.out.println("After setting - Spepsis2[1].taste: " + Spepsis2[1].taste);
        System.out.println("*** Going to set em equal like this Spepsis2 = Spepsis1; *** (Think Array = Array so Object = Object)");
        Spepsis2 = Spepsis1;
        System.out.println("After Equal - Spepsis1[1].taste: " + Spepsis1[1].taste);
        System.out.println("After Equal - Spepsis2[1].taste: " + Spepsis2[1].taste);
        Spepsis2[1].taste = "OK";
        System.out.println("After Changing taste to OK of Spepsis2[1].taste");
        System.out.println("End result after change - Spepsis1[1].taste: " + Spepsis1[1].taste);
        System.out.println("End result after change - Spepsis2[1].taste: " + Spepsis2[1].taste);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("16 ARRAY OF OBJECTS - AN OBJECT ALIASING - ON STRING");
        System.out.println("#################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is an object then it will act like an object - a setting will change reference and it will not a do a copy.");
        System.out.println("PRE-COMMENT: Since above case was also an object the effect will be the same.");
        Pepsi[] Spepsisa1 = new Pepsi[10];
        Pepsi[] Spepsisa2 = new Pepsi[10];
        System.out.println("After init - Spepsisa1[1].taste: ERROR");
        System.out.println("After init - Spepsisa2[1].taste: ERROR");
        Spepsisa1[1] = new Pepsi();
        Spepsisa2[1] = new Pepsi();
        System.out.println("After setting - Spepsisa1[1].taste: " + Spepsisa1[1].taste);
        System.out.println("After setting - Spepsisa2[1].taste: " + Spepsisa2[1].taste);
        System.out.println("*** Going to set em equal like this Spepsisa2[1] = Spepsisa1[1]; *** (Think Object = Object, why object because pepsisa#[X] is an object)");
        Spepsisa2[1] = Spepsisa1[1];
        System.out.println("After equal - Spepsisa1[1].taste: " + Spepsisa1[1].taste);
        System.out.println("After equal - Spepsisa2[1].taste: " + Spepsisa2[1].taste);
        Spepsisa2[1].taste = "OK";
        System.out.println("After Changing taste to OK of Spepsisa2[1].taste");
        System.out.println("End Result - Spepsisa1[1].taste: " + Spepsisa1[1].taste);
        System.out.println("End Result - Spepsisa2[1].taste: " + Spepsisa2[1].taste);
        System.out.println("*** RESULT: Both same so its a REPOINT ***");
        System.out.println("");
        System.out.println("17 ARRAY OF OBJECTS - AN OBJECTS VALUE ALIASING - ON STRING");
        System.out.println("########################################################");
        System.out.println("PRE-COMMENT: Since the subject in mind is a value in this case an int, it will act like the int. So the primatives get copied.");
        Pepsi[] Spepsisaa1 = new Pepsi[10];
        Pepsi[] Spepsisaa2 = new Pepsi[10];
        System.out.println("After Init - Spepsisaa1[1].taste: ERROR");
        System.out.println("After Init - Spepsisaa2[1].taste: ERROR");
        Spepsisaa1[1] = new Pepsi();
        Spepsisaa2[1] = new Pepsi();
        System.out.println("After Setting - Spepsisaa1[1].taste: " + Spepsisaa1[1].taste);
        System.out.println("After Setting - Spepsisaa2[1].taste: " + Spepsisaa2[1].taste);
        System.out.println("*** Going to set em equal like this Spepsisaa2[1].taste = Spepsisaa1[1].taste; *** (Think int = int)");
        Spepsisaa2[1].oz = Spepsisaa1[1].oz;
        System.out.println("After Equal - Spepsisaa1[1].taste: " + Spepsisaa1[1].taste);
        System.out.println("After Equal - Spepsisaa2[1].taste: " + Spepsisaa2[1].taste);
        Spepsisaa2[1].taste = "OK";
        System.out.println("After Changing taste to OK of Spepsisaa2[1].taste");
        System.out.println("End Result - Spepsisaa1[1].taste: " + Spepsisaa1[1].taste);
        System.out.println("End Result - Spepsisaa2[1].taste: " + Spepsisaa2[1].taste);
        System.out.println("*** RESULT: Both different so its a COPY ***");
    }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *