Drop-down lists
Drop-down lists Like a group of radio buttons, a drop-down list is a way to force the user to select only one element from a group of possibilities. However, it’s a much more compact way to accomplish this, and it’s easier to change the elementCiteste tot ... 327 cuvinte
Dimensiune mica - fara poza |
|
|
A method lookup tool
A method lookup tool Chapter 11 introduced the Java 1.1 concept of reflection and used that feature to look up methods for a particular class – either the entire list of methods or a subset of those whose names match a keyword you provide. TheCiteste tot ... 742 cuvinte
Dimensiune mica - fara poza |
|
|
Combining composition and inheritance
Combining composition and inheritance It is very common to use composition and inheritance together. The following example shows the creation of a more complex class, using both inheritance and composition, along with the necessary constructCiteste tot ... 115 cuvinte
Dimensiune mica - fara poza |
|
|
Read-only classes
Read-only classes While the local copy produced by clone( ) gives the desired results in the appropriate cases, it is an example of forcing the programmer (the author of the method) to be responsible for preventing the ill effects of aliaCiteste tot ... 3303 cuvinte
Dimensiune medie - fara imagini |
|
|
for
for A for loop performs initialization before the first iteration. Then it performs conditional testing and, at the end of each iteration, some form of “stepping.” The form of the for loop is: for(initialization; Boolean-expression; Citeste tot ... 257 cuvinte
Dimensiune mica - fara poza |
|
|
Method overloading
Method overloading One of the important features in any programming language is the use of names. When you create an object, you give a name to a region of storage. A method is a name for an action. By using names to describe your system, youCiteste tot ... 553 cuvinte
Dimensiune mica - fara poza |
|
|
RTTI considered harmful
RTTI considered harmful? Various designs in this chapter attempt to remove RTTI, which might give you the impression that it’s “considered harmful” (the condemnation used for poor, ill-fated goto, which was thus never put into Java). This isn’tCiteste tot ... 694 cuvinte
Dimensiune mica - fara poza |
|
|
Guaranteed initialization with the constructor
Guaranteed initialization with the constructor You can imagine creating a method called initialize( ) for every class you write. The name is a hint that it should be called before using the object. Unfortunately, this means the user mustCiteste tot ... 474 cuvinte
Dimensiune mica - fara poza |
|
|
Input and output: Types of InputStream
Input and output The Java library classes for IO are divided by input and output, as you can see by looking at the online Java class hierarchy with your Web browser. By inheritance, all classes derived from InputStream have basic methods calledCiteste tot ... 1043 cuvinte
Dimensiune mica - fara poza |
|
|
The final keyword
The final keyword The final keyword has slightly different meanings depending on the context, but in general it says “This cannot be changed.” You might want to prevent changes for two reasons: design or efficiency. Because these two reasons aCiteste tot ... 1663 cuvinte
Dimensiune medie - fara imagini |
|
|
Windowed applications
Windowed applications It’s possible to see that for safety’s sake you can have only limited behavior within an applet. In a real sense, the applet is a temporary extension to the Web browser so its functionality must be limited along with itsCiteste tot ... 2026 cuvinte
Dimensiune medie - fara imagini |
|
|
Compression: Simple compression with GZIP
Compression Java 1.1 has also added some classes to support reading and writing streams in a compressed format. These are wrapped around existing IO classes to provide compression functionality. One aspect of these Java 1.1 classes standsCiteste tot ... 1606 cuvinte
Dimensiune medie - fara imagini |
|
|
Interfaces
Interfaces The interface keyword takes the abstract concept one step further. You could think of it as a “pure” abstract class. It allows the creator to establish the form for a class: method names, argument lists and return types, but no methoCiteste tot ... 477 cuvinte
Dimensiune mica + cu imagini |
|
|
Alternatives to action
Alternatives to action As noted previously, action( ) isn’t the only method that’s automatically called by handleEvent( ) once it sorts everything out for you. There are three other sets of methods that are called, and if you want to cCiteste tot ... 1322 cuvinte
Dimensiune mica - fara poza |
|
|
A bit about garbage collection
A bit about garbage collection It’s hard to believe that Java could possibly be as fast or faster than C++. This assertion has yet to be proven to my satisfaction. However, I’ve begun to see that many of my doubts about speed come from earlyCiteste tot ... 1789 cuvinte
Dimensiune medie - fara imagini |
|
|
Upcasting
Upcasting The most important aspect of inheritance is not that it provides methods for the new class. It’s the relationship expressed between the new class and the base class. This relationship can be summarized by saying “The new class is aCiteste tot ... 606 cuvinte
Dimensiune mica + cu imagini |
|
|
Comparing C++ and Java
Comparing C++ and Java As a C++ programmer, you already have the basic idea of object-oriented programming, and the syntax of Java no doubt looks familiar to you. This makes sense since Java was derived from C++. However, there are a surprCiteste tot ... 3179 cuvinte
Dimensiune medie - fara imagini |
|
|
Initialization and class loading
Initialization and class loading In many more traditional languages, programs are loaded all at once as part of the startup process. This is followed by initialization, and then the program begins. The process of initialization in these langCiteste tot ... 508 cuvinte
Dimensiune mica - fara poza |
|
|
Applet restrictions
Applet restrictions For safety’s sake, applets are quite restricted and there are many things you can’t do. You can generally answer the question of what an applet is able to do by looking at what it is supposed to do: extend the functionalityCiteste tot ... 827 cuvinte
Dimensiune mica - fara poza |
|
|
Exception restrictions
Exception restrictions When you override a method, you can throw only the exceptions that have been specified in the base-class version of the method. This is a useful restriction, since it means that code that works with the base class will auCiteste tot ... 849 cuvinte
Dimensiune mica - fara poza |
|
|
Alte pagini