freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

外文資料翻譯--一切都是對象(存儲版)

2025-07-01 04:42上一頁面

下一頁面
  

【正文】 還沒有指向某個對象。 Java 中的數(shù)組 幾乎所有的程序設(shè)計語言都支持數(shù)組。也就是說,能作用于 int 或 float 的操作,也能作用于 BigInteger 或 Big Decimal?;绢愋途哂械陌b器類,使得可以在堆中創(chuàng)建一個非基本對象,用來表示對應(yīng)的基本類型。因此,對于這些類型, Java 采取與 C 和 C++相同的方法。而對于持久化 對象,對象保存在磁盤中。 ( 4) 常量 存儲。這一限制無疑影響了程序的靈活性,所以盡管有些Java 數(shù)據(jù)要保存在堆棧里 —— 特別是對象句柄,但 Java 對象并不 存儲于 其中。然而,寄存器的數(shù)量十分有限,所以寄存器是根據(jù)需要由編譯器分配。 當然,字串( String)并非唯一的類型。因此,一種更安全的做法是:創(chuàng)建一個句柄時,記住無論如何都進行初始化: String s = “ zyp” 。但一旦需要“換頻道”或者“關(guān)小聲音”,我們實際操縱的是遙控板(句柄),再有遙控板自己操縱電視機(對象)。 用 句柄操縱對象 每種編程語言都有自己的數(shù)據(jù)處理方式。 無論 C++還是 Java 都屬于 雜合語言 。但在 Java 中,設(shè)計者覺得這種雜合并不像在 C++里那么重要。有些時候,程序員必須時刻留意準備處理的是什么類型。如果要在房間里四處走走,并想保持對電視機的控制,那么手上拿著的是遙控板,而非電 視機。 然而,這里用到了 Java 語言的一個特性 :字串可以用加引號的文本 初始化。 Java 配套提供了數(shù)量 眾 多的現(xiàn)成類型。我們對此沒有直接的控制權(quán),也不可能在自己的程序里找到寄存器存在的任何蹤跡 (另一方面, C 和C++允許您向編譯器建議寄存器的分配方式) 。 ( 3)堆。常數(shù)值通常直接置于程序代碼內(nèi)部。即使程序中止運行,他們?nèi)钥杀3肿约旱臓顟B(tài)不變。也就是說,不用 new 來創(chuàng)建變量,而是創(chuàng)建一個并非是引用的“自動”變量。例如: Char c = ‘ x’ 。 只不過必須以方 法調(diào)用方式取代運算符方式來實現(xiàn)。在 C 和 C++中使用數(shù)組是很危險的,因為 C 和C++中的數(shù)組就是內(nèi)存塊。在使用任何引用前,必須為其指定一個對象;如果試圖使用一個還是 null 的引用,在運行時將會報錯。作用域決定了在其內(nèi)定義的變量名的可見性和生命周期。由于 Java 是一種自由格式( freeform)的語言,所以,空格、制表符、換行都不會影響程序的執(zhí)行結(jié)果。所以假如你采用代碼 { String s = new String(“ a string” )。 這樣便帶來一個有趣的問題。 創(chuàng)建新的數(shù)據(jù)類型:類 如果一切都是對象,那么是什么決定了某一類對象的外觀與行為呢?換句話說,是什么確定了對象的類型?你可能期望有一個名為“ type” 的關(guān)鍵字 ,當然它必須還要有相應(yīng) 的含義。 字段和方法 一旦定義了一個類(在 Java 中你所做的全部工作就是定義類,產(chǎn)生那些類的對象,以及發(fā)送消息給這些對象),就可以在類中設(shè)置兩種類型的元素:字段(有時被稱作數(shù)據(jù)成員)和方法(有時被稱作成員函數(shù))。 可以給字段賦值,但首先必須知道如何引用一個對象的成員。如果想了解成員方法的運行機制,就得先了解參數(shù)和返回值的概念,稍后將對此作簡略描述。如果忘記了這么做, Java 會在編譯時返回一個錯誤。下面是它最基本的形式: ReturnType methodName(/*Argument list*/){ /* Method body*/ } 返回類型描述的是在調(diào)用方法之后從方法返回的值。 例如 ,假設(shè)有一個方法 f(),不帶任何參數(shù),返回類型是 int。因此,在參數(shù)列表中必須指定每個所傳遞對象的類型及名字。在這里, s 的 length()方法被調(diào)用,它是 String 類提供的方法之一,會返回字符串 包含的字符數(shù)。} void nothing2(){} 若返回類型是 void,return 關(guān)鍵字的作用只是用來推出方法。However, this uses a special Java feature: Strings can be initialized with quoted text. Normally, you must use a more general type of initialization for objects. You must create all the objects When you create a reference, you want to connect it with a new object. You do so, in general, with the new operator. The keyword new says, “Make me a new one of these objects.” So in the preceding example, you can say:String s = new String(asdf)。 The reasons for wrapping primitives will be shown in a later chapter. Highprecision numbers Java includes two classes for performing highprecision arithmetic: BigInteger and BigDecimal. Although these approximately fit into the same category as the “wrapper” classes, neither one has a primitive classes have methods that provide analogues for the operations that you perform on primitive types. That is, you can do anything with a BigInteger or BigDecimal that you can with an int or float, it?s just that you must use method calls instead of operators. Also, since there?s more involved, the operations will be slower. You?re exchanging speed for accuracy. BigInteger supports arbitraryprecision integers. This means that you can accurately represent integral values of any size without losing any information during operations. BigDecimal is for arbitraryprecision fixedpoint numbers。 Fields and methods When you define a class (and all you do in Java is define classes, make objects of those classes, and send messages to those objects), you can put two types of elements in your class: fields (sometimes called data members), and methods (sometimes called member functions). A field is an object of any type that you can talk to via its reference, or a primitive type. If it is a reference to an object, you must initialize that reference to connect it to an actual object (using new, as seen earlier). Each object keeps its own storage for its fields。 It is also possible that your object might contain other objects that contain data you?d like to modify. For this, you just keep “connecting the dots.” For example: = 100。 } double naturalLogBase() { return 。 } This method tells you how many bytes are required to hold the information in a particular String. (The size of each char in a String is 16 bits, or two bytes, to support Unicode characters.) The argument is of type String and is called s. Once s is passed into the method, you can treat it just like any other object. (You can send messages to it.) Here, the length( ) method is called, which is one of the methods for Strings。 = 。 // Illegal}}The piler will announce that the variable x has already been defined. Thus the C and C++ ability to “hide” a variable in a larger scop e is not allowed, because the Java designers thought that it led to confusing programs. Scope of objects Java objects do not have the same lifetimes as primitives. When you create a Java object using new, it hangs around past the end of the scope. Thus if you use:{String s = new String(a string)。 Java SE5 autoboxing will automatically convert from a primitive to a wrapper type: Character ch = ?x?。 附件 2:外文 原文 Everything Is an Object “If we spoke a different language, we would perceive a some what different world.” Ludwig Wittgenstein (18891951)Although it is based on C++, Java is more of a “pure” objectoriented language. Both C++ and Java are hybrid languages, but in Java the designers felt that the hybridization was not as important as it was in C++. A hybrid language allows multiple programming styles。} double naturalLogBase(){return 。此方法的參數(shù)類型是 String,參數(shù)名是 s。 參數(shù)列表 方法的參數(shù)列表指定要傳遞給方法什么樣的信息。通過對象調(diào)用方法時,需要先列出對象名,緊接著句點,然后是方法名和參數(shù)列表。 Java 的方法決定了一個對象能夠 接收什么樣的消息。 那么變量 x 得到的可能是任意值(與 C和 C++中一樣),而不會被自動初始化為零。例如: = 100。 Boolean b。 ATypeName a = new ATypeName()。你只需要創(chuàng)建對象,一旦不再需要,他們就會自行消失。這樣,許多 C++編程問題在 Java 中就完全消失了。 對象的作用域 Java 對象不具備和基本類型一樣的生命周期。 任何位于“ //”之后到行末的文字都是注釋。變量需要存活多長時間?如果 想要銷毀對象,那什么時刻進行呢?變量生命周期的混亂往往會導(dǎo)致大量的程序 bug,本節(jié)將介紹 Java 是怎樣替我們完成所有的清理工作,從而大大簡化這個問題的。 當創(chuàng)建一個數(shù)組對象時,實際上就是創(chuàng)建了一個引用數(shù)組,并且每個引用都會自動初始化為一個特定值,該值 擁有自己的關(guān)鍵字 null。 關(guān)于調(diào)用這兩個類的構(gòu)造器和方法的
點擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1