JavaFX has several basic data types, respectively:
integer int type
Number floating-point numbers type
Boolean Logical Type
Duration Time Type
String String type
These types are the same type as the traditional programming languages, which support subtraction, self reduction, small, logical judgment and so on, in fact, which language is the same thing.
The default value: A variable of a basic data type is declared, and if no initial value is assigned, the system is automatically initialized to the default.
Note that this is the basic data type, and if it is an object type, the default value is null.
Third, Duration
Duration type represents a period of time, let's take a look at the Duration example:
5ms; 5 milliseconds
10s; 10 seconds.
30m; 30 points
1h; 1 hours
Describe it in literal quantities, it's clear.
Four, String type
Unlike the traditional syntax, JavaFX's string variables can be either single or double quotes; the other connection string does not use the plus sign, but with curly braces, look at the example to see:
import java.lang.System;
var name = 'Bei Jing';
var message = 'Hello, {name}.';
System.out.println(message);
The result: Hello,bei Jing.
V. Internationalization of strings
Look at the following code:
def mon = ##"Monday";
def about = ##[ABOUT]"JavaFX is a cool scripting language!";
println( mon );
println( about );
If this code is saved in a foo.fx file and then creates a property file under the same path, the filename must look like this: Foo_zh_cn.fxproperties, as follows:
@charset "UTF-8";
"Monday" = "星期一"
"ABOUT" = "JavaFX 是一种很酷的脚本语言!"
In this way, the above code output becomes Chinese. Why is that? Just like you think, the key lies in the double well number # # and the attribute file that conforms to the naming convention.
1, if there is no property file, the system would be # # does not exist, do not make any processing, as is the output.
2, if there is a property file, the system will be based on the current operating system language to decide whether to use, and use which, are based on the file name to judge. If it is not found, it does not make any processing, just output as is. For example: The above example, only works under the Chinese operating system, you put into the French operating system, he will only output English. If we add another property file: Foo_fr_fr.fxproperties, the contents are as follows:
@charset "UTF-8";
"Monday" = "Lundi"
"ABOUT" = "JavaFX est un langage de script cool !"
In this way, the program can display the native language correctly, not only in Chinese but also in the French operating system.