📄 85.txt
字号:
Declaration
A declaration is a statement that declares a class, interface, method, package, or variable in a source file. A declaration can also initialize the variable, although for class members this is normally done in the constructor method.
Default access
A class with default access needs no modifier preceding it in the declaration. Default access allows other classes within the same package to have visibility to this class.
Derived class
A derived class is a class that extends another class. If class d extends class b, then class d “derives” from class b and is a derived class.
Do-while loop
The do-while loop is slightly different from the while statement in that the program execution cycle will always perform the commands in the body of a do-while at least once. It does adhere to the rule that you do not need brackets around the body if it is just one line of code.
Encapsulation
Encapsulation is the process of grouping methods and data together and hiding them behind a public interface. A class encapsulates methods and the data they operate on.
Event classes
All event classes defined in the java.awt.event package are subclasses of java.awt.AWTEvent, which is itself a subclass of java.util.EventObject.
Event objects
An event object embodies information related to a particular type of event. At a minimum, an event object contains a reference to the object that caused the event (the event source). Usually, the event object also contains other data such as mouse position or a timestamp.
Event sources
An event source is a component or object that generates events. Event sources create event objects and deliver them to event listeners. An event source does not have to subclass any specific class or implement any specific interface. Additionally, an object can act as the source of multiple event types, provided that it fulfills the preceding responsibilities for each type.
Event types
An event type is used to distinguish between events that share the same class but have a different purpose.
Exception
Exception has two common meanings in Java. First, an Exception is an object type. Second, an exception is shorthand for “exceptional condition,” which is an occurrence that alters the normal flow of an application.
Exception handling
Exception handling allows developers to easily detect errors without writing special code to test return values. Better, it lets us handle these errors in code that is nicely separated from the code that generated them and handle an entire class of errors with the same code, and it allows us to let a method defer handling its errors to a previously called method. Exception handling works by transferring execution of a program to an exception handler when an error, or exception, occurs.
Extensibility
Extensibility is a term that describes a design or code that can easily be enhanced without being rewritten.
Final class
The final keyword restricts a class from being extended by another class. If you try to extend a final class, the Java compiler will give an error.
Final variables
The final keyword makes it impossible to reinitialize a variable once it has been declared. For primitives, this means the value may not be altered once it is initialized. For objects, the data within the object may be modified, but the reference variable may not be changed. Final variables must be initialized in the same line in which they are declared.
Finalizer
Every class has a special method, called a finalizer, which is called just before an object is reclaimed by the Java VM garbage collector. The JVM calls the finalizer for you as appropriate; you never call a finalizer directly. Think of the finalizer as a friendly warning from the virtual machine. Your finalizer should perform two tasks: performing whatever cleanup is appropriate to the object, and calling the superclass finalizer. If you do not have any cleanup to perform for an object, then you’re better off not adding a finalizer to the class.
Floating-point literals
Floating-point literals are defined as double by default, but if you want to specify in your code a number as float, you may attach the suffix F to the number.
Floating-point numbers
Floating-point numbers are defined as a number, a decimal symbol, and more numbers representing the fraction.
FlowLayout manager
This layout manager arranges components within the container from left to right. When the container runs out of room on the current row FlowLayout resumes positioning components on the next row.
FocusEvent
A component generates a FocusEvent when it gains or loses keyboard focus. The event ID is set to either FOCUS_GAINED or focus lost. There are two types of focus events, permanent and temporary. Permanent focus events indicate that another component has gained the focus, whereas temporary focus events indicate that the component has lost focus temporarily due to window deactivation or scrolling.
For loop
A flow control statement is used when a program needs to iterate a section of code a known number of times. There are three main parts to a for statement. They are the declaration and initialization of variables, the expression, and the incrementing or modification of variables. Each of the sections are separated by semicolons. The for loop is a remarkable tool for developers because it allows you to declare and initialize zero, one, or multiple variables inside the parenthesis after the for keyword.
Garbage collection
The process by which memory requested, but no longer in use, by a Java application is reclaimed by the Java VM.
Generational garbage collectors
Generational garbage collectors make the trade-off of running faster with the cost of leaving garbage lying around longer. With today’s large memory machines, this is a very reasonable trade-off to make.
GridBagLayout layout manager
The GridBagLayout layout manager allows the placement of components that are aligned vertically and/or horizontally without constraining those components to be a particular size, height, or width. The GridBagLayout accomplishes this by defining a dynamic grid of cells. The constraints object passed when the component is added to the container determine how many cells the component encompasses.
GridLayout manager
This layout manager arranges components in a grid within a container. Each cell in the grid is of equal dimensions. The GridLayout manager ignores the preferred size of each component and resizes them to exactly fit each cell’s dimensions. As each component is added to the container the GridLayout inserts them across each column until that row is filled and then starts at the first column of the next row.
Guarded region
A section of code that is watched for errors to be handled by a particular group of handlers.
HashMap class
The HashMap class is roughly equivalent to Hashtable, except that it is not synchronized for threads and it permits null values to be stored.
Heap
Java manages memory in a structure called a heap. Every object that Java creates is allocated in the heap, which is created at the beginning of the application and managed automatically by Java.
Hexadecimal literals
Hexadecimal numbers are constructed using 16 distinct symbols. The symbols used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -