Operators

Mathematical operators 
If you create a Random object  w ith no argument s, Java uses the  current time  as a seed for the random number generator, and will thus produce different output for each execution of the program. 
Relational operators
Equivalence and nonequivalence work with all primitives, but the other
comparisons won’t work with type  boolean. Because  boolean values can only be  true or 
false“greater than” and “less than” doesn’t make sense.
The operators == and != compare object references.
What if you want to compare the actual contents of an object for equivalence? You must use the special method equals( ) that exists for all objects (not primitives, which work fine with == and !=).
The default behavior of equals( ) is to compare references. So unless you override equals( ) in your new class you won’t get the desired behavior.
Logical operators
Notice that when passing  smaller types to  Integer.toBinaryString( )the type is automatically converted to an int.
Bitwise operators
The left-shift operator (<<) produces the operand to the left of the operator after it has been shifted to the left by the number of bits specified to the right of the operator (inserting zeroes at the lower-order bits). The signed right-shift operator (>>) produces the operand to the left of the operator after it has been shifted to the right by the number of bits specified to the right of the operator. The signed right shift >> uses sign extension: If the value is positive, zeroes are inserted at the higher-order bits; if the value is negative, ones are inserted at the higher-order bits. Java has also added the unsigned right shift >>>, which uses zero extension: Regardless of the sign, zeroes are inserted at the higher-order bits .
Truncation and rounding 
Casting from a float or double to an integral value  always truncates the number. If instead you want the result to be rounded, use the round( ) methods in  java.lang.Math
Java has no “sizeof”
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值