亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产精品羞羞答答xxdd | 亚洲伊人色欲综合网| 亚洲大尺度视频在线观看| 日韩不卡免费视频| gogo大胆日本视频一区| 日韩一区二区三区av| 亚洲色图制服诱惑| 国产精品一区二区你懂的| 欧美日韩国产美| 亚洲日韩欧美一区二区在线| 国产一区二区三区久久久| 欧美日韩国产影片| 亚洲日本韩国一区| 成人性色生活片| 国产午夜精品久久久久久免费视| 亚洲午夜精品一区二区三区他趣| kk眼镜猥琐国模调教系列一区二区| 欧美一区二区三区日韩视频| 一区二区三区日韩| 99re热视频精品| 国产女人18毛片水真多成人如厕 | 日韩成人精品在线| 欧美亚洲高清一区| 亚洲精品第1页| 99在线精品观看| 国产精品久久久久久久久免费丝袜 | 99re成人精品视频| 日本一区二区三区久久久久久久久不| 免费成人av资源网| 91精品国产综合久久精品麻豆| 中文字幕亚洲一区二区av在线| 国产精品一区免费在线观看| 欧美成人性福生活免费看| 日韩中文字幕av电影| 欧美午夜视频网站| 洋洋成人永久网站入口| a级高清视频欧美日韩| 国产精品美女一区二区三区| 国产成人日日夜夜| 欧美国产丝袜视频| 成人av网在线| 亚洲女爱视频在线| 91在线视频在线| 亚洲福利电影网| 91麻豆精品91久久久久久清纯| 日韩电影在线观看网站| 欧美成人一区二区三区片免费| 国模无码大尺度一区二区三区| 久久久久久久久久久久电影 | 国产精品一区二区你懂的| 国产日本欧美一区二区| av资源站一区| 夜夜嗨av一区二区三区四季av| 欧美精品乱码久久久久久| 日韩av网站在线观看| 日韩欧美一级精品久久| 国产成人精品在线看| 国产精品久久久久久亚洲毛片| 色久优优欧美色久优优| 午夜视黄欧洲亚洲| 久久综合久久综合久久| av午夜精品一区二区三区| 亚洲一区二区三区小说| 日韩欧美黄色影院| 成人免费视频caoporn| 亚洲精品乱码久久久久久黑人| 91麻豆精品国产91久久久久久久久| 麻豆成人久久精品二区三区小说| 久久久久97国产精华液好用吗| 波波电影院一区二区三区| 亚洲va韩国va欧美va精品| 精品99久久久久久| 日本精品一区二区三区高清| 奇米777欧美一区二区| 亚洲欧洲另类国产综合| 欧美一区二区在线免费观看| 岛国av在线一区| 日本欧洲一区二区| 中文字幕精品综合| 欧美一区二区视频网站| jizzjizzjizz欧美| 激情综合色综合久久| 亚洲精品视频在线| 国产三级精品在线| 欧美日韩精品免费| 99视频在线观看一区三区| 热久久久久久久| 成人久久视频在线观看| 久久免费的精品国产v∧| 男男视频亚洲欧美| 欧美一级理论性理论a| 成人av免费观看| 美女视频黄免费的久久 | av不卡一区二区三区| 日韩精品免费视频人成| 亚洲精品国产a久久久久久| 久久久久久电影| 欧美喷水一区二区| 一本在线高清不卡dvd| 国产在线精品不卡| 久久国产视频网| 舔着乳尖日韩一区| 亚洲一区二区美女| 亚洲免费成人av| 国产精品你懂的在线欣赏| www国产亚洲精品久久麻豆| 欧美日韩一二区| 欧美一区二区三区在线电影| 久久久久久久久久看片| 日韩一区二区三区免费看| 欧美日韩国产综合久久| 在线播放中文字幕一区| 色成人在线视频| 色综合激情五月| 91首页免费视频| 91麻豆文化传媒在线观看| eeuss影院一区二区三区| 成人网在线免费视频| 国产精品1区二区.| 国产成人在线影院| 国产精品888| 成人免费电影视频| 91丨九色丨蝌蚪丨老版| 99国内精品久久| 色8久久人人97超碰香蕉987| 91久久线看在观草草青青| 色综合久久久久久久久久久| 色网站国产精品| 欧美午夜寂寞影院| 在线综合视频播放| 精品99一区二区三区| 欧美国产日韩在线观看| 亚洲天堂2014| 亚洲第一成人在线| 久久99精品视频| 激情成人午夜视频| 成av人片一区二区| 欧美中文字幕一区| 日韩手机在线导航| 欧美激情一二三区| 亚洲精品一二三| 日韩成人精品在线观看| 国产自产v一区二区三区c| 国产91对白在线观看九色| 97精品久久久午夜一区二区三区 | 午夜一区二区三区视频| 免费成人av资源网| 国产福利一区二区| 欧美在线观看视频一区二区 | 久久久不卡网国产精品一区| 国产精品毛片a∨一区二区三区| 亚洲免费av网站| 免费日本视频一区| 成人国产精品视频| 欧美精品在线视频| 中文字幕的久久| 偷拍与自拍一区| 成人午夜免费电影| 日韩丝袜美女视频| 最新日韩在线视频| 久久精品国产一区二区| 色欧美片视频在线观看| 91精品欧美久久久久久动漫| 国产精品日韩成人| 蜜桃av一区二区三区| 91蜜桃在线免费视频| 亚洲精品在线观| 亚洲一区二区影院| 成人免费毛片aaaaa**| 56国语精品自产拍在线观看| 国产精品久久久久久久久免费丝袜 | 亚洲欧洲精品一区二区三区| 免费观看一级欧美片| 91高清在线观看| 国产精品第四页| 国产精品自拍一区| 正在播放一区二区| 亚洲国产中文字幕在线视频综合| 国产凹凸在线观看一区二区| 91麻豆精品91久久久久久清纯| 亚洲欧美激情在线| 成人免费黄色在线| 久久综合丝袜日本网| 蜜臀av性久久久久蜜臀av麻豆| 色婷婷激情一区二区三区| 日本一二三不卡| 国内精品免费**视频| 欧美一区二区视频网站| 亚洲成av人片观看| 日本韩国欧美一区二区三区| 国产精品久久午夜夜伦鲁鲁| 激情五月婷婷综合网| 精品国产伦理网| 精品在线播放免费| 日韩免费电影一区| 免费观看日韩av| 日韩午夜激情免费电影| 日本人妖一区二区| 日韩欧美亚洲一区二区| 久久精品二区亚洲w码|