JavaFX教程-表达式

ZDNet软件频道 时间:2008-08-01 作者: |  我要评论()
本文关键词:表达式 教程 JavaFX 软件
JavaFX支持如下操作符

表达式
JavaFX支持如下操作符:

 
操作符 含义 Java等价物
 
关系操作符
== equality ==
<> inequality !=
< less than <
> greater than >
<= less than or equal <=
>= greater than or equal >=
 
布尔操作符 
and logical and &&
or logical or ||
not logical negation !
 
算术操作符
+ addition +
- subtraction; unary negation -
* multiplication *
/ division /
% remainder %
+= add and assign +=
-= subtract and assign -=
*= multiply and assign *=
/= divide and assign /=
%= remainder and assign %=
 
其它操作符
sizeof array length n/a
indexof ordinal position n/a
ife1thene2elsee3 conditional expression e1?e2:e3
select list comprehension n/a
foreach list comprehension n/a
new allocation new
op() function/operation call n/a
x.op() member function/operation call x.op()
instanceof type check instanceof
this self access this
. attribute access, context access ., n/a
bind [lazy] incremental [lazy] evaluation n/a
: eager initialization n/a
[] array selection []
format as String formatting n/a
<<>> Identifier quotes n/a
{} String expression n/a
(expr) grouping (expr)
reverse reverses a list n/a
[number1,next..number2] numeric range n/a

一些示例:

import java.lang.System;
 import java.lang.Math;
 
 var x = 2;
 var y = 4;
 var a = true;
 var b = false;
 System.out.println(x == y);  // prints false
 System.out.println(x <> y);  // prints true
 System.out.println(x < y);   // prints true
 System.out.println(x > y);   // prints true
 System.out.println(x >= y);  // prints false
 System.out.println(x <= y);  // prints true
 System.out.println(x + y);   // prints  6
 System.out.println(x - y);   // prints  -2
 System.out.println(x * y);   // prints  8
 System.out.println(x / y);   // prints  0.5
 System.out.println(x % y);   // prints  2
 System.out.println(a and b); // prints  false
 System.out.println(a or b);  // prints  true
 System.out.println(not a);   // prints  false
 System.out.println(sizeof [x,y]);   // prints  2
 System.out.println([x,y][indexof . == 0]);   // prints  2
 System.out.println(if a then x else y); // prints 2
 System.out.println(select q from q in [x, y] where q > 3); prints 4
 System.out.println(foreach(q in [x, y] where q < 3) q); prints 2
 System.out.println(Math.max(x, y)); // prints 4
 System.out.println("abc".toUpperCase()); // prints ABC
 System.out.println(x instanceof Number); // prints true
 x = 10;
 System.out.println(x); // prints 10

表达式

教程

JavaFX

软件


百度大联盟认证黄金会员Copyright© 1997- CNET Networks 版权所有。 ZDNet 是CNET Networks公司注册服务商标。
中华人民共和国电信与信息服务业务经营许可证编号:京ICP证010391号 京ICP备09041801号-159
京公网安备:1101082134