麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

CertificationNotes(中英對照)

2019-11-18 14:30:51
字體:
來源:轉載
供稿:網友

  Initialization
  初始化
  * All class-level (member) variables are initialized before they can be used.
   All local variables are not initialized until it is done eXPlicitly.
   
  * 所有的主成員在他們使用之前被初始化所有的局部變量必須通過顯式的賦值來初始化
  
  * An array object (as distinct from reference) is always initialized(with zeroes or nulls)
  
  * 數組對象總是能夠初始化(零或者null)
  
  * Member initialization with the declaration has exception PRoblems:
  - cannot call methods that throw a checked exception.
  - cannot do error recovery from runtime exceptions.
  - If you need to deal with errors you can put the initialization code along with try/catch statements in either a ctor (for instance fields) or in a static initialization block for static fields. You can also have instance (non-static) initialization blocks but ctors are more recognizable.
  
  * 需要處理異常的成員初始化
  - 不能調用會拋出異常的方法
  - 不能對基本異常做任何處理
  - 假如你需要處理錯誤,將初始化的代碼放到構造器或者靜態初始化塊的 try/catch塊中,當然,你也可以放到非靜態的代碼塊中,但是構造器似乎更為通用。
  
  Strings
  字符串
  * The String class
   - Because string is an immutable class, its instance methods that look like they would transform the object they are invoked upon, do not alter the object and instead return new String objects.
   - String has methods concat(String),trim(),replace(char,char)
   - String has static valueOf methods for a whole bunch of primitives and for Object too (equivalent to Object.toString()).
   - in substring(int,int), the second arg is exclusive.
   - indexOf methods returns -1 for 'not found'
  
  * 類String
   - 類String是不可變的,即使他的某些方法看起來會改變字符串的內容,但實際上他們返回的是一個新的字符串,而不是改變原來的字符串
   - 類String的方法:cancat(String),trim(),replace(char,char)
   - 類String的靜態方法valueOf能處理所有的基本類型和對象(調用對象的toString()方法)
   - 在substring(int,int)方法中,第二個參數是"不包括"的(譯者注:第一個參數是"包括"的,例如substring(1,4)將會返回字符串從第二個字符開始(包括第二個字符),到第五個字符結束(不包括第五個字符)的子字符串)
   - 假如沒有找到,indexOf方法將返回-1
  
  * String Pool:
   A JVM has a string pool where it keeps at most one object of any String. String literals always refer to an object in the string pool. String objects created with the new Operator do not refer to objects in the string pool but can be made to using String's intern() method. Two String references to 'equal' strings in the string pool will be '=='.
  
  * 字符串池
   虛擬機有一個字符串池,保存著幾乎所有的字符串對象。字符串表達式總是指向字符串池中的一個對象。使用new操作創建的字符串對象不指向字符串池中的對象但是可以使用intern方法使其指向字符串池中的對象(譯者注:假如池中已經有相同的字符串--使用equals方法確定,則直接返回池中的字符串,否則先將字符串添加到池中,再返回)。池中兩個相等的字符串假如使用'=='來比較將返回真
  
  * StringBuffer doesn't override equals.
  
  * 類StringBuffer沒有覆蓋equals方法
  
  Arrays
  數組
  * Arrays are objects .. the following create a reference for an int array.
    int[] ii;
    int ii[];
  
  * 數組是一個對象 .. 下面的代碼創建一個整型數組的引用:
    int[] ii;
    int ii[];
  
  * You can create an array object with new or an explicit initializer:
    ii = new int[3];
    ii = new int[] { 1,2,3 };
    int[] ii = { 1,2,3 ); // only when you declare the reference.
  
  * 你可以通過new操作或者顯式的初始化創建一個數組對象:
    ii = new int[3];
    ii = new int[] { 1,2,3 };
    int[] ii = { 1,2,3 }; // 只有聲明的時候
  
  * CAREFUL: You can't create an array object with:
    int iA[3];
  
  * 小心:你不能象下面這樣創建一個數組對象:
      int iA[3];
  * If you don't provides values, the elements of obj arrays are always initialized to null and those of primitive arrays are always initialized to 0.
  
  * 假如你不提供初始值,對象數組的元素總是初始化成null,基本類型數組的元素總是初始化成零
  
  Primitive Types
  基本類型
  * Primitive types:
   - short and char are both 2 bytes.
    int and float are both 4 bytes.
    long and double are both 8 bytes.
   - char is the only unsigned primitive type.
  
  * 基本類型:
   - short和char的長度是兩個字節。
      int和float的長度都是四個字節。
      long和double的長度都是八個字節。
   - char是唯一的無符號基本類型
  
  * Literals:
   - You can have boolean, char, int, long, float, double and String literals.
    You cannot have byte or short literals.
   - char literals: 'd' '/u0c20' (the 0c20 must be a 4-digit hex number).
   - int literals: 0x3c0 is hex, 010 is octal(for 8).
   - You can initialize byte, short and char variables with int literals(or const int expressions) provided the int is in the appropriate range.
  
  * 表達式
  - 只有boolean,char,int,long,float,double和字符串的表達式;沒有byte和short的表達式
  - 字符(char)表達式:'d'、'/u0c20'(0c20必須是四位的十六進制數字)
  - 整型(int)表達式:0x3c0是十六進制形式,010是八進制形式
  - 可是使用合法范圍內的整型表達式對byte、short和char變量初始化
  
  * CAREFUL: can't assign a double literal to a float .. float fff = 26.55;
  
  * 小心:不能將一個double表達式賦給一個float變量 .. float fff = 26.55;
  
  * The only bit operators allowed for booleans are &^ (cant do ~ or shift ops)
  
  * 位運算只有&^(不能使用~或者移位操作)
  
  * Primitive wrapper classes
    - are immutable.
    - override equals.
    - the static valueOf(String) methods in primitive wrapper classes return wrapper objects rather than a primitives.
  
  * 基本類型的包裝類
   - 不可變的
   - 覆蓋equals方法
   - 靜態方法valueOf(String)返回的是包裝類而不是基本類型
  
  Conversions and Promotions
  類型轉換
  * boolean->anything but boolean or string is not allowed.
  * All other primitive conversions are allowed with an explicit cast.
  * char/byte/short/int/long to float/double is a widening conversion even if some precision is lost (the overall magnitude is always preserved).
  * Narrowing conversions require an explicit cast.
   - integral narrowing conversions simply discard high-order bits.
   - anything to char is a narrowing conversion (inc byte) because its signed to unsigned and negative numbers get messed up
  
  * boolean不能跟其它的任何類型相互轉換,但是boolean->String是答應的
  * 所有的基本類型之間可以通過顯式的類型轉換而轉變成其它類型
  * char/byte/short/int/long到float/double的轉換是寬轉換,即使有可能丟掉部分信息
  * 窄轉換需要顯式的轉換
   - 整型的窄轉換只簡單的去掉高位比特
   - 所有到char的轉換都是窄轉換(包括byte)因為轉換是從有符號數到無符號數
    的轉換,負數將會得到一個混亂的結果
  
  * Widening primitive and reference conversions are allowed for assignment and in matching the arguments to a method (or ctor) call.
  
  * 對象和基本類型的寬轉換答應在賦值和匹配的方法調用中(非顯式的)使用
  
  * For assignment (but not method invocation), representable constant int expressions can be converted to byte, char or shorts (eg. char c = 65).
  
  * 賦值時,合法的整型表達式能被自動轉換成byte、char或者short(例如:char c = 65)
  
  * Unary numeric promotions: byte/short/char to int

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美黄色三级视频 | 日韩在线欧美在线 | 中午日产幕无线码1区 | 亚洲视频高清 | 国产小视频在线 | 欧美亚洲一级 | 精品一区二区三区免费毛片 | 爽爽淫人综合网网站 | 美国一级黄色毛片 | 99影视电影电视剧在线播放 | 日本黄色大片免费 | 91美女视频在线观看 | 国产毛毛片一区二区三区四区 | 91九色蝌蚪国产 | 黄色的视频在线观看 | 日日操夜夜透 | h视频免费在线观看 | 在线高清中文字幕 | 日本成人一区二区 | 97久久曰曰久久久 | 一区在线不卡 | 久草热久 | va毛片 | 午夜爽爽爽男女免费观看hd | www.精品久久 | 日本在线视频二区 | 国产精品久久久麻豆 | 毛片网站视频 | 国产99久久久国产精品 | 羞羞视频免费网站含羞草 | 国产成年人小视频 | 成人午夜免费在线观看 | 亚洲第一综合色 | 国产一区毛片 | av成人免费看 | 免费色片| 日韩在线毛片 | 欧美xxxxx视频 | 免费人成在线播放 | www.99re14.com| 黄网站色成年大片免费高 |