
BBj Object Assignment
Description
Assignment of a number or string to an object variable copies the value. For example, after executing these lines of code, subsequent changes to X will not affect X! In addition, subsequent changes to Y$ will not affect Y!:
LET X! = X |
Assignment of any other value to an object variable copies a reference. For example, after executing these lines of code, subsequent changes to A! will be reflected in X!, because they are pointers to the same ArrayList:
LET A! = new java.util.ArrayList() |
Some objects define a clone() method to create a copy of a complex data structure. See the Java documentation for details. For example:
LET A! = new java.util.ArrayList() |
A Java expression that returns a Java array can be assigned directly to a BBj array, as in these examples:
REM ' Locale![]
is a BBj array of java.util.Locale objects |
In BBj 18.0 and higher, Java arrays can be created with thenewoperator, and can be directly manipulated using syntax similar to that of traditional BBj arrays:
use java.awt.Color |