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

正文內(nèi)容

網(wǎng)上書店管理系統(tǒng)外文資料翻譯-管理系統(tǒng)-在線瀏覽

2025-03-24 02:53本頁面
  

【正文】 n (the object) and a remote control 1(the reference). 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。Not only does this mean “Make me a new String,” but it also gives information about how to make the String by supplying an initial character string. Of course, Java es with a plethora of readymade types in addition to String. What?s more important is that you can create your own types. In fact, creating new types is the fundamental activity in Java programming, and it?s what you?ll be learning about in the rest of this book.. Where storage lives It?s useful to visualize some aspects of how things are laid out while the program is running—in particular how memory is arranged. There are five different places to store data: 1. Registers. This is the fastest storage because it exists in a place different from that of other storage: inside the processor. However, the number of registers is severely limited, so registers are allocated as they are needed. You don?t have direct control, nor do you see any evidence in your programs that registers even exist (C amp。 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?。 Or you could also use: Character ch = new Character(?x?)。 and back:char c = ch。 you can use these for accurate moary calculations, for example. Consult the JDK documentation for details about the constructors and methods you can call for these two classes. Arrays in Java Virtually all programming languages support some kind of arrays. Using arrays in C and C++ is perilous because those arrays are only blocks of memory. If a program accesses the array outside of its memory block or uses the memory before initialization (mon programming errors), there will be unpredictable results. One of the primary goals of Java is safety, so many of the problems that plague programmers in C and C++ are not repeated in Java. A Java array is guaranteed to be initialized and cannot Thinking in Java be accessed outside of its range. The range checking es at the price of having a small amount of memory overhead on each array as well as verifying the index at run time, but the assumption is that the safety and increased productivity are worth the expense (and Java can sometimes optimize these operations). When you create an array of objects, you are really creating an array of references, and each of those references is automatically initialized to a special value with its own keyword: null. When Java sees null, it recognizes that the reference in question isn?t pointing to an object. You must assign an object to each reference before you use it, and if you try to use a reference that?s still null, the problem will be reported at run time. Thus, typical array errors are prevented in Java. You can also create an array of primitives. Again, the piler guarantees initialization because it zeroes the memory for that will be covered in detail in later chapters. You never need todestroy an object In most programming languages, the concept of the lifetime of a variable occupies a significant portion of the programming effort. How long does the variable last? If you are supposed to destroy it, when should you? Confusion over variable lifetimes can lead to a lot of bugs, and this section shows how Java greatly simplifies the issue by doing all the cleanup work for you. Scoping Most procedural languages have the concept of scope. This determines both the visibility and lifetime of the names defined within that scope. In C, C++, and Java, scope is determined by the placement of curly braces {}. So for example: { int x = 12。// Both x amp。 {int x = 96。} // 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 w
點(diǎn)擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計(jì)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1