国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

CertificationNotes(中英對(duì)照)

2019-11-18 14:30:51
字體:
供稿:網(wǎng)友

  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)
  
  * 數(shù)組對(duì)象總是能夠初始化(零或者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.
  
  * 需要處理異常的成員初始化
  - 不能調(diào)用會(huì)拋出異常的方法
  - 不能對(duì)基本異常做任何處理
  - 假如你需要處理錯(cuò)誤,將初始化的代碼放到構(gòu)造器或者靜態(tài)初始化塊的 try/catch塊中,當(dāng)然,你也可以放到非靜態(tài)的代碼塊中,但是構(gòu)造器似乎更為通用。
  
  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是不可變的,即使他的某些方法看起來會(huì)改變字符串的內(nèi)容,但實(shí)際上他們返回的是一個(gè)新的字符串,而不是改變原來的字符串
   - 類String的方法:cancat(String),trim(),replace(char,char)
   - 類String的靜態(tài)方法valueOf能處理所有的基本類型和對(duì)象(調(diào)用對(duì)象的toString()方法)
   - 在substring(int,int)方法中,第二個(gè)參數(shù)是"不包括"的(譯者注:第一個(gè)參數(shù)是"包括"的,例如substring(1,4)將會(huì)返回字符串從第二個(gè)字符開始(包括第二個(gè)字符),到第五個(gè)字符結(jié)束(不包括第五個(gè)字符)的子字符串)
   - 假如沒有找到,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 '=='.
  
  * 字符串池
   虛擬機(jī)有一個(gè)字符串池,保存著幾乎所有的字符串對(duì)象。字符串表達(dá)式總是指向字符串池中的一個(gè)對(duì)象。使用new操作創(chuàng)建的字符串對(duì)象不指向字符串池中的對(duì)象但是可以使用intern方法使其指向字符串池中的對(duì)象(譯者注:假如池中已經(jīng)有相同的字符串--使用equals方法確定,則直接返回池中的字符串,否則先將字符串添加到池中,再返回)。池中兩個(gè)相等的字符串假如使用'=='來比較將返回真
  
  * StringBuffer doesn't override equals.
  
  * 類StringBuffer沒有覆蓋equals方法
  
  Arrays
  數(shù)組
  * Arrays are objects .. the following create a reference for an int array.
    int[] ii;
    int ii[];
  
  * 數(shù)組是一個(gè)對(duì)象 .. 下面的代碼創(chuàng)建一個(gè)整型數(shù)組的引用:
    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操作或者顯式的初始化創(chuàng)建一個(gè)數(shù)組對(duì)象:
    ii = new int[3];
    ii = new int[] { 1,2,3 };
    int[] ii = { 1,2,3 }; // 只有聲明的時(shí)候
  
  * CAREFUL: You can't create an array object with:
    int iA[3];
  
  * 小心:你不能象下面這樣創(chuàng)建一個(gè)數(shù)組對(duì)象:
      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.
  
  * 假如你不提供初始值,對(duì)象數(shù)組的元素總是初始化成null,基本類型數(shù)組的元素總是初始化成零
  
  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的長度是兩個(gè)字節(jié)。
      int和float的長度都是四個(gè)字節(jié)。
      long和double的長度都是八個(gè)字節(jié)。
   - char是唯一的無符號(hào)基本類型
  
  * 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.
  
  * 表達(dá)式
  - 只有boolean,char,int,long,float,double和字符串的表達(dá)式;沒有byte和short的表達(dá)式
  - 字符(char)表達(dá)式:'d'、'/u0c20'(0c20必須是四位的十六進(jìn)制數(shù)字)
  - 整型(int)表達(dá)式:0x3c0是十六進(jìn)制形式,010是八進(jìn)制形式
  - 可是使用合法范圍內(nèi)的整型表達(dá)式對(duì)byte、short和char變量初始化
  
  * CAREFUL: can't assign a double literal to a float .. float fff = 26.55;
  
  * 小心:不能將一個(gè)double表達(dá)式賦給一個(gè)float變量 .. float fff = 26.55;
  
  * The only bit operators allowed for booleans are &^ (cant do ~ or shift ops)
  
  * 位運(yùn)算只有&^(不能使用~或者移位操作)
  
  * Primitive wrapper classes
    - are immutable.
    - override equals.
    - the static valueOf(String) methods in primitive wrapper classes return wrapper objects rather than a primitives.
  
  * 基本類型的包裝類
   - 不可變的
   - 覆蓋equals方法
   - 靜態(tài)方法valueOf(String)返回的是包裝類而不是基本類型
  
  Conversions and Promotions
  類型轉(zhuǎn)換
  * 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不能跟其它的任何類型相互轉(zhuǎn)換,但是boolean->String是答應(yīng)的
  * 所有的基本類型之間可以通過顯式的類型轉(zhuǎn)換而轉(zhuǎn)變成其它類型
  * char/byte/short/int/long到float/double的轉(zhuǎn)換是寬轉(zhuǎn)換,即使有可能丟掉部分信息
  * 窄轉(zhuǎn)換需要顯式的轉(zhuǎn)換
   - 整型的窄轉(zhuǎn)換只簡單的去掉高位比特
   - 所有到char的轉(zhuǎn)換都是窄轉(zhuǎn)換(包括byte)因?yàn)檗D(zhuǎn)換是從有符號(hào)數(shù)到無符號(hào)數(shù)
    的轉(zhuǎn)換,負(fù)數(shù)將會(huì)得到一個(gè)混亂的結(jié)果
  
  * Widening primitive and reference conversions are allowed for assignment and in matching the arguments to a method (or ctor) call.
  
  * 對(duì)象和基本類型的寬轉(zhuǎn)換答應(yīng)在賦值和匹配的方法調(diào)用中(非顯式的)使用
  
  * For assignment (but not method invocation), representable constant int expressions can be converted to byte, char or shorts (eg. char c = 65).
  
  * 賦值時(shí),合法的整型表達(dá)式能被自動(dòng)轉(zhuǎn)換成byte、char或者short(例如:char c = 65)
  
  * Unary numeric promotions: byte/short/char to int

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡东县| 巫溪县| 盐源县| 白沙| 镇远县| 繁昌县| 墨脱县| 峨边| 于田县| 城市| 宁安市| 眉山市| 峨山| 肇东市| 谢通门县| 武汉市| 通河县| 渭南市| 疏勒县| 太谷县| 钦州市| 大悟县| 平南县| 昭通市| 阜新| 罗平县| 扎鲁特旗| 连南| 湖口县| 琼中| 丽水市| 辉县市| 黑水县| 正镶白旗| 乌审旗| 海门市| 合江县| 苏州市| 建湖县| 长阳| 吉首市|