JavaFX in simple and profound (II.) basic data types

Source: Internet
Author: User
Tags naming convention

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.