[Core Java. Volume I. Fundamentals, 8th Edition]-2,3

 String[] greeting = new String[3];
      greeting[0] = "Welcome to Core Java";
      greeting[1] = "by Cay Horstmann";
      greeting[2] = "and Gary Cornell";

      for (String g : greeting)
         System.out.println(g);

相当于as3中的

for each(var g :String in greeting) trace(g);

-----------------------------------------------

data types


必须初始化

After you declare a variable, you must explicitly initialize it by means of an assignment statement—you can never use the values of uninitialized variables.

                      int vacationDays; 
                      System.out.println(vacationDays); // ERROR--variable not initialized 


In Java, it is considered good style to declare variables as closely as possible to the point  where they are first used

const is a reserved Java keyword, but it is not currently used for anything. You must use final for aconstant


关于strictfp

If you tag a class as strictfp, then all of its methods use strict floating-point computations. 

 public static strictfp void main(String[] args) 
外链拓展

>>>and>>

a >>> operator fills the top bits with zero, whereas >> extends the sign bit into the top bits. There is no <<< operator

CAUTION: The right-hand side argument of the shift operators is reduced modulo 32 (unless theleft-hand side is a long, in which case the right-hand side is reduced modulo 64).  For example, the value of1 << 35 is the same as 1 << 3 or 8.


                   

   *   If either of the operands is of typedouble, the other one will be converted to a double
                   *   Otherwise, if either of the operands is of type float, the other one will be converted to a float
                   *    Otherwise, if either of the operands is of type long, the other one will be converted to a long
                   *    Otherwise, both operands will be converted to an int


枚举

     enum Size { SMALL, MEDIUM, LARGE, EXTRA_LARGE }; 
                   Now you can declare variables of this type: 
                       Size s = Size.MEDIUM; 




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值