Magazine
 
Quick Review:JavaFX
 
Working with JavaFX Classes and Objects

attribute firstvalue: Integer;
attribute secondvalue: Integer;
attribute thirdvalue: Number = 15;

Attribute’s value can be assigned at the place of declaration. If they are not initialized explicitly the default value is assigned.

2. Functions:

Functions represent behavior of the object. Its syntax is:

function functionName (parameterName : parameterType, .…….): returnType function_body

For example:

function add(value1: Integer, value2: Integer): Integer {
return value1 + value2;
}

iv) Variables and Basic Data Types
1. Variables

To create a variable in the program ‘var’ keyword is used. Its syntax can be as below:

var variableName : type = initializer;

For example:

var title = “JavaJazzUp”;
var variable1 = 1;
var variable2 : Number = 2;

2. Basic Data Types

JavaFX has five basic datatypes:

1. String (as java.lang.String in Java programming language)
2. Boolean (as java.lang. Boolean in Java programming language)
3. Number (as java.lang. Number in Java programming language)
4. Integer (as byte,short,int,long,BigInteger in Java programming language)
5. Duration

The Duration type is one of the new type in JavaFX. This class represents a unit of time (millisecond, second, minute, or hour). We can instantiate this class using time literal also.

1ms; // 1 milliseconds
2s; // 2 seconds
3m; // 3 minutes
4h; // 4 hour

Aug 2008 | Java Jazz Up | 21
 
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