The Java Programming Language Notes

zhaozj2021-02-12  134

1, Static MEMBER

You can use this type of object to reference this class static membsomeclass obj = null; obj.StaticMethod (); obj.StaticData = 1;

Use the object to reference the static member is not recommended, but why not ban like C #?

2, multiple inheritance faces the same method as the signature of multiple interfaces, the subclasses seem to provide only one realization, how is the correctness of the semantic? C # can provide an implementation in the subclass of the same method for the same method of inheriting from multiple interfaces.

3, local class, anonymous class, internal class

The only problem provided by the innovative grammatical facilities provided by the language in the design, do not abuse

4, array of confusion

It seems that violation of the "basket of apples is not a basket", in the need for the base class array, it can pass the number array, and lose the type of compile period, and avoid errors by running abnormality.

5, evaluation order

Clearly specified from left to right, good

6, the role domain

Local variables, parameters can shield member variables The local variables of the member variable cannot be equal to the parameters that are more local, and the same name is good with the peripheral variable.

7, comma expression

No comma expression, it is not

8, Break Label

Powerful, replace Flag, Goto

9, abnormal

It is the AOP of that level relative to the return error code.

10. Abnormal declarations and return values ​​from different treatments

The same is not the basis for OVERLOAD. When OVERRIDE is Override, the abnormal statement can be relaxed to a subclass, but the return value cannot be enlarged as a subclass based on the same reason.

11, class lock and instance lock

Unhealthy

12, the server synchronization with the client

The former mainly protects its internal data, the latter mainly guarantees the call sequence

13, main

Everything Has A Begin, Has An end ------- Matrix revolution I guess the beginning, but can't guess this ending ---- Xianren

The Java program starts with main, but it is not necessarily in the last User thread. The child is still having fun, Sun is a child; there is a child, and there is a grandchildren. Son grandson, nothing

Do you have a chicken or egg? What is the origin of a person? What is the origin of life? Perhaps one day people divert back to the extreme, but found that JVM launched Main, when the world was destroyed, but JVM collapsed

Length, .NET thread is similar to this

14, J2SE 1.5 retrogression

Static introduction Static Import formatted Output formatted Output formatted input formatted INPUT Uncertain parameters VARARGS

I can't believe that Ning Kenchi does not learn C

15, Proxy

Template in C was intended to Generic Programming, but unintentionally discovered powerful features of its geneative programming; I don't know what the initial intention in Java, but causing generations of geneative programming another form - AOP's trend

16, ClassLoader

Opening a back door in the program, a class's bytecode downloads from my personal website, don't be discovered by the customer, I will change it, huh, huh 17, language, library, platform, blur border

String connection operator " " is part of the language or part of the library? When serialization / reverse sequence is a private method that can be modified by a virtual machine is part of the language or part of the library? SoftRefrence, WEAKREFRENCE, etc. are used by virtual machines to process objects such as core language features such as the core language characteristics, is part of language or part of the library?

Java is not a platform-independent, it itself is a platform; not saying it is not good, but there is such a difference with the traditional language.

18, @ deprecated

Compared to XDoclets and other features, it touches the Java's nerve earlier: Note actually affects the behavior of the compiler! I finally developed Java with marking.

19. Different ideas of Override

Java / C #: As long as access rights allow, you can call the rewritable method, no matter whether the sub-object constructed is not C : As long as the sub-object constructed, you can call the rewriting method, no matter the access

The consequences result are:

Java / C #: Call the method in the base class constructor, as long as the subclass has permission overwriting, the implementation C of the subclass is adjusted to the subclass: The method called in the base class constructor / destructor is always the base class. Implementation, it will not be adjusted to the subclass; it will always be transferred to the subclass of overwriting, no matter whether it is private

20, IO

The byte is no semantics, so the stream character is semantic, so called Reader and Writer.

Need to have no semantics, called InputStreamReader, OutputStreamWriter, called Dataxxx, object serialization, called Objectxxx

21, java.io.file

Live the wrong place, it is actually abstraction of the file system, and there is no too much relationship with IO, you should put it in the system package, follow the THREAD.

22, Collectes

The general design principle is that the pre-conditions of the sub-rewriting method should be weak in the parent class, but the COLLECTION and its subclasses have no appropriate compliance with this principle, and there is a scope of application; Collection's design purpose is As common as possible, not the time of running, you still need to choose the appropriate specific data structure, although it is sometimes only passed through the Collection interface

23, Iterator

Unlike STL, Iterator provides internal secure REMOVE (), and partially provides add (); but the end of traversal is unsafe, and it is different from STL. Itrator can sense the external changes, throw an exception from me to protect my protection. Instead of producing undefined behaviors

24, Timer (), TIMER (TRUE)

The most commonly used is not the most convenient, you have to remember the parameters; you can use two creation methods, you can use two subclasses, even if you use parameters, you should use the enumeration reel, hey, forget 1.5 no enumeration before, That is a static constant, New Timer (Timer.deamon) and New Timer (TRUE), which clearer?

25, fragile private

In addition to serialization / reverse selecinstement, access is destroyed by the platform. Under the default security settings, class.newinstance () can also build a CTOR declared as an instance of the class of Private, the result is that I wish to force customer code to use IOC The developer of the principle, which can be reassured to declare the BEAN's CTOR as Private.

(The C # Programming Language Notes (the corner of J2SE 5.0)

转载请注明原文地址:https://www.9cbs.com/read-6779.html

New Post(0)