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 |