Magazine
 
Quick Review:JavaFX
 
Working with JavaFX Classes and Objects

The sequence can also be created as below:

var numbers = [10,20,30,40];
var names = [“Java”, “FX”];

Sequences are not objects but the ordered list of objects. If their length and elements are equal then they are considered to be equal.

For example, the code:

var myArray:Integer[];
myArray =[10,20];
java.lang.System.out.println(“Equal? “+ {myArray == [10,20]});

Gives output as below:

Equal? true

It has one interesting feature: It provides a short notation ‘..’ for sequences in arithmetic series.

For example, the code below:

var values = [1..50]; // No need to type all numbers from 1 to 50.
java.lang.System.out.println(“values[0]: “+ values[0]);
java.lang.System.out.println(“values[1]: “+ values[1]);
java.lang.System.out.println(“values[2]: “+ values[2]);
java.lang.System.out.println(“values[49]: “+ values[49]);

Gives output as below:

values[0]: 1
values[1]: 2
values[2]: 3
values[49]: 50

Inserting an element into a sequence:

Syntax for inserting a new element in the sequence is like below:

insert n into mySequence;
insert n before mySequence [index];
insert n after mySequence [index];

For example, the code below:

var mySequence = [1..5];
insert 7 into mySequence;
insert 6 before mySequence [5];

Aug  2008 | Java Jazz Up |25
 
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,

58, 59, 60, 61, 62, 63 Download PDF