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

正文內(nèi)容

網(wǎng)上書(shū)店管理系統(tǒng)外文資料翻譯-管理系統(tǒng)-預(yù)覽頁(yè)

 

【正文】 ence). As long as you?re holding this reference, you have a connection to the television, but when someone says, “Change the channel” or “Lower the volume,” what you?re manipulating is the reference, which in turn modifies the object. If you want to move aroundthe room and still control the television, you take the remote/reference with you, not the television. Also, the remote control can stand on its own, with no television. That is, just because you have a reference doesn?t mean there?s necessarily an object connected to it. So if you want to hold a word or sentence, you create a String reference: But here you?ve created only the reference, not an object. If you decided to send a message to s at this point, you?ll get an error because s isn?t actually attached to anything (there?s no television). A safer practice, then, is always to initialize a reference when you create it:String s = asdf。 it is only defined to be able to take the literal values true or “wrapper” classes for the primitive data types allow you to make a nonprimitive object on the heap to represent that primitive type. For example: char c = ?x?。 and back:char c = ch。// Both x amp。} // End of scopethe reference s vanishes at the end of the scope. However, the String object that s was pointing to is still occupying memory. In this bit of code, there is no way to access the object after the end of the scope, because the only reference to it is out of scope. In later chapters you?ll see how the reference to the object can be passed around and duplicated during the course of a program. It turns out that because objects created with new stay around for as long as you want them, a whole slew of C++ programming problems simply vanish in Java. In C++ you must not only make sure that the objects stay around for as long as you need them, you must also destroy the objects when you?re done with brings up an interesting question. If Java leaves the objects lying around, what keeps them from filling up memory and halting your program? This is exactly the kind of problem that would occur in C++. This is where a bit of magic happens. Java has a garbage collector, which looks at all the objects that were created with new and figures out which ones are not being referenced anymore. Then it releases the memory for those objects, so the memory can be used for new objects. This means that you never need to worry about reclaiming memory yourself. You simply create objects, and when you no longer need them, they will go away by themselves. This eliminates a certain class of programming problem: the socalled “memory leak,” in which a programmer fets to release memory. Creating new data types: class If everything is an object, what determines how a particular class of object looks and behaves? Put another way, what establishes the type of an object? You might expect there to be a keyword called “type,” and that certainly would have made sense. Historically, however, most object oriented languages have used the keyword class to mean “I?m about to tell you what a new type of object looks like.” The class keyword (which is so mon that it will not usually be boldfaced throughout this book) is followed by the name of the new type. For example: class ATypeName { /* Class body goes here */ } This introduces a new type, although the class body consists only of a ment (the stars and slashes and what is inside, which will be discussed later in this chapter), so there is not too much that you can do with it. However, you can create an object of this type using new:ATypeName a = new ATypeName()。boolean b。 = false。 it will not automatically be initialized to zero. You are responsible for assigning an appropriate value before you use x. If you fet, Java definitely improves on C++: You get a piletime error telling you the variable might not have been initialized. (Many C++ pilers will warn you about uninitialized variables, but in Java these are errors.) Methods,arguments,and return values In many languages (like C and C++), the term function is used to describe a named subroutine. The term that is more monly used in Java is method, as in “a way to do something.” If you want, you can continue thinking in terms of functions. It?s really only a syntactic difference, but this book follows the mon Java usage of the term “method” Methods in Java determine the messages an object can receive. The fundamental parts of a method are the name, the arguments, the return type, and the body. Here is the basic form: ReturnType methodName( /* Argument list */ ) { /* Method body */} The return type describes the value that es back from the method after you call it. The argument list gives the types and names for the information that you want to pass into the method. The method name and argument list (which is called the signature of the method) uniquely identify that method. Methods in Java can be created only as part of a class. A method can be called only for an object,3 and that object must be able to perform that method call. If you try to call the wrong method for an object, you?ll get an error message at pile time. You call a method for an object by naming the object followed by a period (dot), followed by the name of the method and its argument list, like this:object Name. method N ame(arg1, arg2, arg3)。 it returns the number of characters in a string. You can also see the use of the return keyword, which does two things. First, it means “Leave the method, I?m done.” Second, if the method produces a value, that value is placed right after the return statement. In this case, the return value is produced by evaluating the expression ( ) * 2. You can return any type you want, but if you don?t want to return anything at all, you do so by indicating that the method returns void. Here are some examples: boolean flag() { return true
點(diǎn)擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計(jì)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1