亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? operators and assignments(.txt

?? 499篇java文章
?? TXT
字號:
作者:jeru
email: jeru@163.net
日期:7/3/2001 9:55:32 AM
5)Operators and Assignments
Objective 1)
Determine the result of applying any operator including assignment operators and instanceof to operands of any type class scope or accessibility or any combination of these.
1.    Unary operators.
1.1    Increment and Decrement operators ++ --
We have postfix and prefix notation. In post-fix notation value of the variable/expression is modified after the value is taken for the execution of statement. In prefix notation, value of the variable/expression is modified before the value is taken for the execution of statement.

x = 5; y = 0; y = x++;  Result will be x = 6, y = 5
x = 5; y = 0; y = ++x;  Result will be x = 6, y = 6

Implicit narrowing conversion is done, when applied to byte, short or char.

1.2    Unary minus and unary plus + -
+ has no effect than to stress positivity.
- negates an expression’s value. (2’s complement for integral expressions)
1.3    Negation !
Inverts the value of a boolean expression.
1.4    Complement ~
Inverts the bit pattern of an integral expression. (1’s complement – 0s to 1s and 1s to 0s)
(~i=-i-1)
Cannot be applied to non-integral types.
1.5    Cast ()
Persuades compiler to allow certain assignments. Extensive checking is done at compile and runtime to ensure type-safety.

2.    Arithmetic operators - *, /, %, +, - 
·    Can be applied to all numeric types. 
·    Can be applied to only the numeric types, except ‘+’ – it can be applied to Strings as well.
·    All arithmetic operations are done at least with ‘int’. (If types are smaller, promotion happens. Result will be of a type at least as wide as the wide type of operands)
·    Accuracy is lost silently when arithmetic overflow/error occurs. Result is a nonsense value.
·    Integer division or % by zero throws ArithmeticException.
·    Floating point arithmetic always loses precision. The following code fragment returns false.
float f = 1.0 F / 3.0 F; 
if ( A * 3.0 F == 1.0 F ) return true; 
else return false;
·    % - sign of the result entirely determined by sign of LHS
·    Floating point calculations can produce NaN (square root of a negative no. or % by zero) or Infinity/-Infinity( division by zero). Float and Double wrapper classes have named constants for NaN and infinities.
·    NaN’s are non-ordinal for comparisons. X ==  Float.NaN won’t work. Use Float.IsNaN(x) and Double.IsNaN(x). But equals method on wrapper objects(Double or Float) with NaN values compares Nan’s correctly.
·    Infinities are ordinal. X == Double.POSITIVE_INFINITY will give expected result.
·    + also performs String concatenation (when any operand in an expression is a String). The language itself overloads this operator. toString() method of non-String object operands are called to perform concatenation. In case of primitives, a wrapper object is created with the primitive value and toString method of that object is called. (“Vel” + 3 will work.)
·    Be aware of associativity when multiple operands are involved.
System.out.println( 1 + 2 + “3” ); // Prints 33
System.out.println( “1” + 2 + 3 ); // Prints 123

3.    Shift operators - <<, >>, >>>
·    << performs a signed left shift. 0 bits are brought in from the right. Sign bit (MSB) is preserved.(?) Value becomes old value * 2 ^ x where x is no of bits shifted.
·    >> performs a signed right shift. Sign bit is brought in from the left. (0 if positive, 1 if negative. Value becomes old value / 2 ^ x where x is no of bits shifted. Also called arithmetic right shift.
·    >>> performs an unsigned logical right shift. 0 bits are brought in from the left. This operator exists since Java doesn’t provide an unsigned data type (except char). >>> changes the sign of a negative number to be positive. So don’t use it with negative numbers, if you want to preserve the sign. Also don’t use it with types smaller than int. (Since types smaller than int are promoted to an int before any shift operation and the result is cast down again, so the end result is unpredictable.)
·    Shift operators can be applied to only integral types.
·    -1 >> 1 is –1, not 0. 
·    1 << 31 will become the minimum value that an int can represent. 
·    Negative numbers are represented in two’s complement notation. (Take one’s complement and add 1 to get two’s complement)
·    Shift operators never shift more than the number of bits the type of result can have. ( i.e. int 32, long 64) RHS operand is reduced to RHS % x where x is no of bits in type of result.  
int x; 
x == x >> 32 // ture
x =  x >> 33;  // Here actually what happens is x >> 1
·    if right side is negative, for int, use low 5 bits; for long, use low 6 bits.

4.    Comparison operators – all return boolean type.
4.1    Ordinal comparisons - <, <=, > , >= 
·    Only operate on numeric types. Test the relative value of the numeric operands.
·    Arithmetic promotions apply. char can be compared to float.
4.2    Object type comparison – instanceof
·    Tests the class of an object at runtime. Checking is done at compile and runtime same as the cast operator.
·    Returns true if the object denoted by LHS reference can be cast to RHS type.
·    LHS should be an object reference expression, variable or an array reference.
·    RHS should be a class (abstract classes are fine), an interface or an array type, castable to LHS object reference. Compiler error if LHS & RHS are unrelated.
·    Can’t use java.lang.Class or its String name as RHS.(?)
·    Returns true if LHS is a class or subclass of RHS class
·    Returns true if LHS implements RHS interface.
·    Returns true if LHS is an array reference and of type RHS.
·    x instanceof Component[] – legal.
·    x instanceof [] – illegal. Can’t test for ‘any array of any type’
·    Returns false if LHS is null, no exceptions are thrown.
·    If x instanceof Y is not allowed by compiler, then Y y = (Y) x is not a valid cast expression. If x instanceof Y is allowed and returns false, the above cast is valid but throws a ClassCastException at runtime. If x instanceof Y returns true, the above cast is valid and runs fine.
4.3    Equality comparisons - ==, !=
·    For primitives it’s a straightforward value comparison. (promotions apply)
·    For object references, this doesn’t make much sense. Use equals method for meaningful comparisons. (Make sure that the class implements equals in a meaningful way, like for X.equals(Y) to be true, Y instance of X must be true as well)
·    For String literals, == will return true, this is because of compiler optimization.
5.    Bit-wise operators - &, ^, |
·    Operate on numeric and boolean operands.
·    & - AND operator, both bits must be 1 to produce 1.
·    | - OR operator, any one bit can be 1 to produce 1.
·    ^ - XOR operator, any one bit can be 1, but not both, to produce 1.
·    In case of booleans true is 1, false is 0.
·    Order:  AND, XOR, OR.
·    Can’t cast any other type to boolean.

6.    Short-circuit logical operators - &&, ||
·    Operate only on boolean types.
·    RHS might not be evaluated (hence the name short-circuit), if the result can be determined only by looking at LHS.
·    false && X  is always false.
·    true || X is always true.
·    RHS is evaluated only if the result is not certain from the LHS.

7.    Ternary operator
·    Format a = x ? b : c ;
·    x should be a boolean expression.
·    Based on x, either b or c is evaluated. Both are never evaluated.
·    b will be assigned to a if x is true, else c is assigned to a.
·    b and c should be assignment compatible to a. 
·    b and c are made identical during the operation according to promotions. 

8.    Assignment operators.
·    Simple assignment =.
·    op= calculate and assign operators(extended assignment operators)
·    *=, /=, %=, +=, -=
·    x += y means x = x + y. But x is evaluated only once. Be aware.
·    Assignment of reference variables copies the reference value, not the object body.
·    Assignment has value, value of LHS after assignment. So a = b = c = 0 is legal. c = 0 is executed first, and the value of the assignment (0) assigned to b, then the value of that assignment (again 0) is assigned to a. 
·    Extended assignment operators do an implicit cast. (Useful when applied to byte, short or char)
byte b = 10;
b = b + 10; // Won’t compile, explicit cast reqd since the expression evaluates to an int
b += 10; // OK, += does an implicit cast from int to byte

9.    General
·    In Java, No overflow or underflow of integers happens. i.e. The values wrap around. Adding 1 to the maximum int value results in the minimum value. 
·    Always keep in mind that operands are evaluated from left to right, and the operations are executed in the order of precedence and associativity.  
·    Unary Postfix operators and all binary operators (except assignment operators) have left to right assoiciativity.
·    All unary operators (except postfix operators), assignment operators, ternary operator, object creation and cast operators have right to left assoiciativity.
·    Inspect the following code.
public class Precedence {
  final public static void main(String args[]) {
    int i = 0; 
    i = i++; 
    i = i++; 
    i = i++;
    System.out.println(i); // prints 0, since = operator has the lowest precedence.
    
    int array[] = new int[5];
    int index = 0;
array[index] = index = 3; // 1st element get assigned to 3, not the 4th element

    for (int c = 0; c < array.length; c++)
      System.out.println(array[c]);    
    System.out.println("index is " + index); // prints 3    
  }
}

Type of Operators    Operators    Associativity
Postfix operators    [] . (parameters) ++ --    Left to Right
Prefix Unary operators    ++  -- + - ~ !    Right to Left
Object creation and cast    new (type)    Right to Left
Multiplication/Division/Modulus    * / %    Left to Right
Addition/Subtraction    + -    Left to Right
Shift    >> >>> <<    Left to Right
Relational    < <= > >= instanceof    Left to Right
Equality    == !=    Left to Right
Bit-wise/Boolean AND    &    Left to Right
Bit-wise/Boolean XOR    ^    Left to Right
Bit-wise/Boolean OR    |    Left to Right
Logical AND (Short-circuit or Conditional)    &&    Left to Right
Logical OR (Short-circuit or Conditional)    ||    Left to Right
Ternary    ? :    Right to Left
Assignment    = += -= *= /= %= <<= >>= >>>= &= ^= |=    Right to Left




?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷综合久久久中文一区二区| 日韩精品电影一区亚洲| 欧美日韩不卡一区二区| 91亚洲精品久久久蜜桃| 成人妖精视频yjsp地址| 国产91丝袜在线观看| 国产乱对白刺激视频不卡| 国产一区二区三区久久久 | 国产午夜精品福利| 久久精品这里都是精品| 欧美激情一区三区| 国产精品妹子av| 亚洲视频网在线直播| 亚洲综合一二区| 婷婷开心激情综合| 午夜精品久久久久| 经典一区二区三区| 成人av中文字幕| 91福利在线免费观看| 欧美精品电影在线播放| 欧美一级视频精品观看| 精品久久人人做人人爱| 国产精品三级久久久久三级| 国产精品国产精品国产专区不蜜 | 亚洲综合丝袜美腿| 首页综合国产亚洲丝袜| 久久国产精品色| 不卡一卡二卡三乱码免费网站| 欧美做爰猛烈大尺度电影无法无天| 欧美日韩国产123区| 2014亚洲片线观看视频免费| 国产欧美日产一区| 亚洲国产精品自拍| 国产乱码字幕精品高清av| 91欧美一区二区| 日韩欧美中文字幕制服| 亚洲视频免费看| 久久99精品久久久久婷婷| 91色porny在线视频| 精品国产99国产精品| 亚洲精品福利视频网站| 精品中文字幕一区二区| 91精彩视频在线观看| 亚洲永久精品大片| 国产在线播放一区三区四| 欧美最猛性xxxxx直播| 久久久久久99久久久精品网站| 一二三四区精品视频| 国产精品888| 91精品国产欧美日韩| 亚洲精品中文字幕乱码三区| 精品一区在线看| 欧美日韩高清一区| 亚洲日本va午夜在线电影| 国产美女精品一区二区三区| 欧美日韩精品一区二区三区蜜桃| 国产亚洲美州欧州综合国| 日韩精品每日更新| 色噜噜狠狠色综合中国| 国产精品色婷婷久久58| 国产乱子轮精品视频| 欧美一卡2卡3卡4卡| 亚洲电影一级片| 色综合天天做天天爱| 国产精品美女一区二区在线观看| 精品中文字幕一区二区| 欧美一区二区播放| 青青草97国产精品免费观看无弹窗版 | 国产精品人人做人人爽人人添| 麻豆久久久久久久| 在线播放欧美女士性生活| 亚洲国产综合色| 欧美自拍偷拍午夜视频| 亚洲综合色成人| 精品视频123区在线观看| 亚洲精品国产精华液| 在线视频你懂得一区二区三区| 亚洲日本一区二区三区| 91久久一区二区| 三级欧美在线一区| 亚洲三级理论片| 亚洲国产成人精品视频| 在线日韩av片| 日韩高清不卡一区| 日韩无一区二区| 国产一区二区网址| 日韩一区在线看| 欧美性xxxxxxxx| 麻豆专区一区二区三区四区五区| 欧美一二三在线| 国产精品一区一区三区| 国产精品免费免费| 欧美色倩网站大全免费| 青草国产精品久久久久久| 2023国产精品| 波多野结衣精品在线| 亚洲黄色免费网站| 欧美一级欧美一级在线播放| 国产一区在线视频| 亚洲天堂免费看| 91精品国产综合久久久久久漫画| 激情成人综合网| 自拍偷拍亚洲综合| 欧美一级视频精品观看| 丁香六月综合激情| 亚洲18女电影在线观看| 欧美精品一区二区三区四区| 成年人国产精品| 蜜臀久久99精品久久久久宅男| 亚洲成av人影院| xf在线a精品一区二区视频网站| 豆国产96在线|亚洲| 亚洲成人免费看| 亚洲国产高清在线| 欧美一区二区三区系列电影| 国产精品1区2区3区在线观看| 一区二区三区欧美日| 日韩精品中文字幕一区| 91丨九色丨黑人外教| 韩国成人精品a∨在线观看| 亚洲人成在线观看一区二区| 日韩欧美123| 欧美曰成人黄网| 成人少妇影院yyyy| 久久电影网电视剧免费观看| 亚洲精品乱码久久久久久久久 | 久色婷婷小香蕉久久| 亚洲精品免费在线观看| 国产人成亚洲第一网站在线播放| 在线不卡a资源高清| 欧洲人成人精品| 成人h版在线观看| 久久av老司机精品网站导航| 亚洲成人激情av| 亚洲精品福利视频网站| 综合激情成人伊人| 中文在线资源观看网站视频免费不卡| 日韩欧美国产精品一区| 9191国产精品| 在线成人小视频| 91精品欧美福利在线观看| 欧美视频完全免费看| 91亚洲永久精品| jizzjizzjizz欧美| caoporm超碰国产精品| 国产98色在线|日韩| 国产精品自拍在线| 国产精品中文有码| 韩国午夜理伦三级不卡影院| 久久爱www久久做| 麻豆国产精品一区二区三区| 丝袜国产日韩另类美女| 午夜激情久久久| 婷婷激情综合网| 日韩中文字幕亚洲一区二区va在线| 亚洲国产综合人成综合网站| 亚洲第一福利视频在线| 亚洲福利一区二区三区| 天堂久久久久va久久久久| 日韩精品电影一区亚洲| 精品制服美女丁香| 国产一区二区中文字幕| 成人a区在线观看| 91国产成人在线| 欧美人xxxx| xfplay精品久久| 亚洲欧美自拍偷拍| 亚洲综合色自拍一区| 视频在线观看91| 国产一区二区三区免费播放| 国产99精品国产| 欧美性受xxxx黑人xyx性爽| 欧美男人的天堂一二区| 欧美精品一区二区三区在线| 欧美高清一级片在线观看| 国产精品成人午夜| 丝袜美腿亚洲色图| 国产精品一二二区| 色综合久久九月婷婷色综合| 欧美久久高跟鞋激| 久久精品亚洲精品国产欧美| ...av二区三区久久精品| 午夜精品久久久| 欧美日韩国产在线观看| 26uuu国产一区二区三区| 国产精品乱人伦| 水野朝阳av一区二区三区| 国产成人免费视频精品含羞草妖精 | 黄色资源网久久资源365| 成人自拍视频在线观看| 欧美视频三区在线播放| 久久久久久久久久久久久夜| 一区二区三区精品在线| 激情另类小说区图片区视频区| 99精品国产热久久91蜜凸| 日韩欧美亚洲国产另类| 亚洲制服丝袜av| 成人毛片视频在线观看| 欧美一区二区视频在线观看2022 | 97精品久久久午夜一区二区三区 |