javaFX语法笔记

javaFX语法笔记

1.insert语句
可以用下面方式中的任意一种进行声明:

 insert Expression1 [as first | as last] into Expression2
 insert Expression1 before Expression2
 insert Expression1 after Expression2

eg:
 var x = [1,2,3];
 insert 12 into x; // yields [1,2,3,12]
 insert 10 as first into x; // yields [10,1,2,3,12]
 insert [99,100] as last into x; // yields [10,1,2,3,12,99,100]
 var x = [1,2,3];
 insert 10 after x[. == 10]; // yields [1,2,3,10]
 insert 12 before x[1]; // yields [1,12,2,3,10]
 insert 13 after x[. == 2]; // yields [1, 12, 2, 13, 3, 10];

2.delete语句
delete语句可以使用下面形式中的一种:

 delete variable
 delete Expression.attribute
 delete variable[predicate]
 delete Expression.attribute[predicate]

eg:
 var x = [1,2,3];
 insert 10 into x; // yields [1,2,3,10]
 insert 12 before x[1]; // yields [1,12,2,3,10]
 delete x[. == 12]; // yields [1,2,3,10]
 delete x[. >= 3]; // yields [1,2]
 insert 5 after x[. == 1]; // yields [1,5,2];
 insert 13 as first into x; // yields [13, 1, 5, 2];
 delete x; // yields []

3.一些语法的实例:
 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

4.字符串(String)、数值(Number)和日期的格式化
JavaFX有内建的字符串格式化操作符(format as),语法如下:

 表达式 format as 指令

format as 操作符支持java.text.DecimalFormat、java.text.SimpleDateFormat和java.util.Formatter的格式化指令:如果格式化指令以%开头,那么将会使用java.util.Formatter;如果表达式是Number类型,则使用java.text.DecimalFormat;如果表达式是java.util.Date类型,则使用java.text.SimpleDateFormat。指令操作数是一个在语法上的标识符,而不是一个表达式。这就允许了在编译时静态检查指令内容的正确性。

例如:
 import java.util.Date;

 100.896 format as <<%f>>; // yields ‘100.896000’
 31.intValue() format as <<%02X>>; // yields ‘1F’
 var d = new Date();
 d format as <<yyyy-MM-dd’T’HH:mm:ss.SSSZ>>; // yields ‘2005-10-31T08:04:31.323-0800’
 0.00123 format as <<00.###E0>>; // yields ‘12.3E-4’

5.Try语句
JavaFX的try语句用法类似Java,但它具有JavaFX变量声明语法。注意:在JavaFX中,任意对象都能够被抛出和捕捉,而并非仅仅是java.lang.Throwable的继承类。

例如:

 try {
  throw "Hello";
 } catch (s:String) {
  System.out.println("caught a String: {s}");
 } catch (any) {
  System.out.println("caught something not a String: {any}");
 } finally {
  System.out.println("finally…");
 }

6.关于全局变量的例子
 myString:String = "This is a string";//这是个全局的变量
 var myString:String = "cool";

 System.out.println(myString:String);
 System.out.println(myString);
 
 //函数内部的变量
 operation test(){
  var myString = "a";
  System.out.println(myString:String);
  System.out.println(myString);
 }

 test();

——–>
output:
 This is a string
 cool
 This is a string
 a

3 thoughts on “javaFX语法笔记

  1. wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you wWorld of Warcraft gold ordered!

    wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold -44172518753934

  2. Hi,Do you have used LCDs, used flat screens and secondhand LCDs? Please go here:www.sstar-hk.com(Southern Stars).We are constantly buying re-usable LCD panels and working for LCD recycling.The re-usable panels go through strictly designed process of categorizing, checking, testing, repairing and refurbishing before they are re-used to make remanufactured LCD displays and TV sets.Due to our recent breakthrough in testing and repairing technology of LCD, we can improve the value for your LCD panels.
    Contact Us
    E-mail:sstar@netvigator.com
    website:www.sstar-hk.com[iaaaiaddah

  3. wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold
    wow gold -229728266316227

Leave a Reply

Your email address will not be published. Required fields are marked *