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

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

?? operators and assignments(1).txt

?? 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一区二区三区免费野_久草精品视频
欧美三级视频在线观看| 日韩一区二区免费在线电影| 免费看欧美美女黄的网站| 国产午夜亚洲精品理论片色戒| 欧美性生活久久| 国产电影一区在线| 日韩国产成人精品| 亚洲色图19p| 久久久国际精品| 欧美一区二区国产| 91久久国产综合久久| 国产成人精品免费一区二区| 日韩 欧美一区二区三区| 一区二区三区在线观看国产| 国产偷v国产偷v亚洲高清| 欧美一区二区美女| 欧美日韩国产高清一区二区| av在线播放成人| 国产美女主播视频一区| 日韩高清一级片| 午夜精品成人在线视频| 一区二区三区蜜桃| 亚洲视频一二三区| 国产精品国产三级国产有无不卡| 久久老女人爱爱| 欧美电影免费观看高清完整版在线 | 亚洲成av人在线观看| 中文字幕字幕中文在线中不卡视频| 久久蜜桃一区二区| 久久综合九色综合欧美就去吻| 日韩一级免费观看| 欧美一区二区三区四区在线观看 | 欧美亚洲精品一区| 在线免费观看日韩欧美| 色综合天天综合狠狠| 成人app下载| 99久久精品免费看国产| 成人免费毛片a| 成人激情午夜影院| 成av人片一区二区| 99vv1com这只有精品| 色综合天天综合狠狠| 色呦呦网站一区| 91福利国产成人精品照片| 91福利社在线观看| 欧美高清视频一二三区| 91精品啪在线观看国产60岁| 日韩免费性生活视频播放| 日韩欧美国产不卡| 久久夜色精品一区| 国产精品久久久久久久久图文区| 亚洲欧洲精品一区二区三区 | 午夜精品久久久久久久| 日韩成人精品在线| 久久精品国产99| 国产suv精品一区二区6| 波多野结衣精品在线| 欧美做爰猛烈大尺度电影无法无天| 在线一区二区观看| 欧美一区二区三区四区久久| 日韩免费性生活视频播放| 国产喷白浆一区二区三区| 亚洲日本在线观看| 亚洲成av人片在线| 韩国av一区二区三区四区| 成人小视频免费观看| 色婷婷av一区二区三区软件| 91精品国产综合久久小美女| 久久久久国产免费免费| 一区二区三区欧美在线观看| 日本午夜精品一区二区三区电影| 国产一区二区电影| 91九色最新地址| 欧美mv日韩mv亚洲| 国产精品电影院| 日本vs亚洲vs韩国一区三区二区| 国产精品亚洲第一| 欧美吞精做爰啪啪高潮| 精品国产一区二区精华| 国产精品第四页| 日本不卡的三区四区五区| 国产suv精品一区二区三区| 欧美日韩国产一区| 亚洲国产精品ⅴa在线观看| 亚洲成人激情自拍| 国产精品2024| 9191久久久久久久久久久| 国产欧美中文在线| 亚洲v中文字幕| 成人网男人的天堂| 日韩天堂在线观看| 夜夜夜精品看看| 国产成人精品网址| 日韩欧美一级在线播放| 亚洲欧美日韩一区| 国产麻豆午夜三级精品| 欧美吞精做爰啪啪高潮| 国产精品国产三级国产aⅴ入口| 三级成人在线视频| 91片在线免费观看| 久久久久国产一区二区三区四区| 亚洲在线中文字幕| 北条麻妃国产九九精品视频| 日韩精品一区二区三区在线观看 | 精品国产髙清在线看国产毛片| 亚洲精品成a人| 成人免费看视频| 精品国产精品网麻豆系列| 午夜精品久久久久影视| www.av精品| 国产日韩欧美不卡| 国产在线播放一区| 在线电影国产精品| 亚洲一区二区欧美激情| 不卡的看片网站| 国产欧美精品一区二区色综合朱莉| 老汉av免费一区二区三区| 欧美日韩在线播放三区四区| 中文字幕日韩一区二区| 成人短视频下载| 国产亚洲欧美在线| 国产一区二区在线看| 日韩一区二区三区三四区视频在线观看| 亚洲精品国产a| 一本色道久久综合精品竹菊| 亚洲天堂2014| 91香蕉视频污在线| 中文字幕佐山爱一区二区免费| 国产99一区视频免费| 国产亚洲人成网站| 国产成人av电影免费在线观看| 2021中文字幕一区亚洲| 国产麻豆精品一区二区| 精品久久久久香蕉网| 精品中文字幕一区二区| 精品国产电影一区二区| 国产在线播放一区三区四| 久久一留热品黄| 国产成人综合视频| 国产人伦精品一区二区| av网站免费线看精品| 中文字幕一区日韩精品欧美| 91在线视频免费观看| 一区二区三区在线视频免费| 欧洲另类一二三四区| 日韩在线一区二区| 日韩欧美中文字幕公布| 国产精品综合在线视频| 国产女主播在线一区二区| www.日韩av| 亚洲国产美国国产综合一区二区| 欧美日韩久久久一区| 免费视频最近日韩| 久久精品欧美一区二区三区麻豆| 成人午夜在线视频| 夜夜操天天操亚洲| 7777精品伊人久久久大香线蕉 | hitomi一区二区三区精品| 亚洲欧洲中文日韩久久av乱码| 色综合天天综合狠狠| 亚洲成av人片在线| 精品国产伦理网| 99精品视频一区二区| 亚洲成人动漫av| 精品国产凹凸成av人导航| 99久久精品费精品国产一区二区| 夜色激情一区二区| 精品久久一二三区| 成人国产精品免费观看动漫| 亚洲国产成人av好男人在线观看| 精品免费99久久| 97久久超碰国产精品| 天天综合色天天| 日本一区二区三区高清不卡| 欧美午夜精品一区二区蜜桃| 国产在线观看一区二区| 一区二区三区 在线观看视频| 欧美电影免费观看完整版 | 亚洲精品在线观看视频| 91麻豆国产在线观看| 免费观看在线色综合| 亚洲欧美中日韩| 日韩欧美一区二区在线视频| 成人av网址在线| 日韩国产欧美在线播放| 中文字幕综合网| 亚洲精品一线二线三线| 欧美在线播放高清精品| 国产成人精品影院| 日本视频中文字幕一区二区三区| 国产精品久久久爽爽爽麻豆色哟哟 | 9久草视频在线视频精品| 日本不卡高清视频| 亚洲人xxxx| 久久精品人人做| 欧美va在线播放| 欧美视频在线一区二区三区 | voyeur盗摄精品| 国精产品一区一区三区mba桃花 | 亚洲一区二区三区免费视频|