JavaFX教程-表达式

上一篇 / 下一篇  2008-03-18 16:50:41 / 个人分类:Javafx

表达式

JavaFX支持如下操作符:

操作符含义Java等价物
关系操作符
==equality==
<>inequality!=
<less than<
>greater than>
<=less than or equal<=
>=greater than or equal>=
布尔操作符
andlogical and&&
orlogical or||
notlogical negation!
算术操作符
+addition+
-subtraction; unary negation-
*multiplication*
/division/
%remainder%
+=add and assign+=
-=subtract and assign-=
*=multiply and assign*=
/=divide and assign/=
%=remainder and assign%=
其它操作符
sizeofarray lengthn/a
indexofordinal positionn/a
ife1thene2elsee3conditional expressione1?e2:e3
selectlist comprehensionn/a
foreachlist comprehensionn/a
newallocationnew
op()function/operation calln/a
x.op()member function/operation callx.op()
instanceoftype checkinstanceof
thisself accessthis
.attribute access, context access., n/a
bind [lazy]incremental [lazy] evaluationn/a
:eager initializationn/a
[]array selection[]
format asString formattingn/a
<<>>Identifier quotesn/a
{}String expressionn/a
(expr)grouping(expr)
reversereverses a listn/a
[number1,next..number2]numeric rangen/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

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2012-02-10  
   1234
567891011
12131415161718
19202122232425
26272829   

数据统计

  • 访问量: 93437
  • 日志数: 171
  • 影音数: 3
  • 建立时间: 2008-02-28
  • 更新时间: 2008-05-19

RSS订阅

Open Toolbar