more effective java

Discover more effective java, include the articles, news, trends, analysis and practical advice about more effective java on alibabacloud.com

Effective java--End Method Guardian

Directory:Effective java--End Method GuardianEffective Java Chapter 2nd: Creating and Destroying objects. 7th: Avoid using the finalization method. The last example of the "End Method Guardian (finalizer Guardian)" to deepen understanding.1 /**2 * Chapter 2--end Guardian3 * @ClassName: Parent4 * TODO5 * @authorXingle6 * @date 2015-3-11 pm 3:49:477 */8 Public classParent {9 Ten Public Static void

Effective Java generics

Generics are a feature introduced by Java in the JDK1.5 version, which greatly enhances the security of Java code runtime, where generics are primarily used in container classes, because these classes contain a wide variety of other classes, so you need to use generics to constrain the classes contained in the container, such as passing in a string type parameter to the list Number, then, the list object ca

[Reading notes] Effective Java Chapter Fourth

policy with a function objectIn Java, where there is a similar set of sequencer, the Sequencer object only represents the strategy of sorting, such instances of the class is functionally not different, mutual equivalence, suitable as a singleton, saving unnecessary object creation overhead.prioritize static member classesStatic member classes are the simplest kind of nested classes. If the member class does not require access to the perimeter instanc

Effective Java-Avoid using finalizer

JNI calls.These JNI methods is coded in C or C + +. They do the actual work, interacting with a native label.Let's look at the figure.You can see this AWT components provide a universal public API to the application by AWT component class and AWT peers. A Component class and its peer interface is identical across platform. Those underlying peer classes and JNI codes are different. ) In addition, finalizer chaining was mentioned. The subclass constructor automatically calls the parent class con

Effective Java reading notes creating and destroying objects

Today just began to read effective Java, the Chinese version of the reading is very awkward, but feel a lot of harvest.In addition, the content of this book is for Java 1.5 and 1.6.Here's the 2nd Chapter: Creating and destroying the contents of an object.First: Consider replacing the constructor with a static factory methodThis article is intended for scenarios w

Effective Java Directory

"Effective Java" catalog excerpt.I know it looks bad. In the present, the lack of actual operation, can only temporarily extract the directory. With the increase in practice, fill in more examples slowly.Chapter 2 Creating and destroying Objects Consider static factory methods instead of constructors Consider a builder when faced with many constructor parameters Enforce the Singleton proper

"Regain effective Java" one

Before reading this book "Effective Java (second edition)" is very early. This book is indeed a good book. You need to chew slowly and have a different experience every time you look.Write a blog here to consolidate.Chapter I. Creating and Destroying objects Consider replacing the constructor with a static factory methodUsually we get an instance of the class, and the more frequently used method is to use t

Effective Java-Interface or abstract class

There are two mechanisms for Java to provide multiple implementations of an abstraction-Interface and abstract class.Interface and abstract class,In addition to the obvious differences (i.e., the ability to provide a basic implementation),The important difference is that the implementation class for an interface can be at any point in the class hierarchy, and the subclass of the abstract class is subject to this limitation. Existing classes c

Effective Java version 2nd-notes (01) enumeration (enum) implementation of a singleton (Singleton)

Directly on the code:1 Public enumBoss {2 3 INSTANCE;4 5 PrivateString name;6 7 Public voiddosomething () {8SYSTEM.OUT.PRINTLN (name + "is doing something now ...");9 }Ten One PublicString GetName () { A returnname; - } - the Public voidsetName (String name) { - This. Name =name; - } - +}Note: The enum in Java is a thoroughly-bottomed class that can be freely added to other properties and methods, so

Java experience (1. Postfix mail delivery performance and effective delivery issues)

corresponding domain name queue, send and update the last send time of the changed domain name.2. Unlock the domain to send records.In this way, the non-blocking queue is used for message queue, which improves the concurrency of the system.It seems to solve the problem, but it was blacklisted by some service providers.The system is then analyzed as follows:This is a typical producer-to-consumer issue in which Java client-produced messages are timed t

Effective Java enum class

With the effective Java this book to see more and more, found in peacetime use of Java made a lot of obvious mistakes, they usually know a little but the lack of use is also more and more.As for enumeration classes, the suggestion in the book is to replace the traditional static constants with enumeration classes, usually, if a class of data is represented by a d

Effective Java--> (i) Creating and destroying objects

Create | objects Effective Java Learning notes the Java language supports four basic types: interface (Interface), Class (Class), array (array), and primitive type (primitive). The first three types are often referred to as reference types (reference type), instances and arrays of classes are objects (object), and the values of primitive types are not objects. A

[Effective Java Reading notes] Chapter II Creating and destroying objects sixth-? Reviews

Sixth elimination of expired referencesThere will still be memory leak in Java, such as a stack growth and contraction, then the object pops from the stack will not be garbage collected, the immediate use of the stack of the program no longer reference these objects. This is because the inside of the stack maintains outdated references to these objects (which are never dismissed) and needs to be shown to empty (null) the objects and tell the garbage c

Effective Java Reading notes of the seven general programming

rather than classes to refer to objects.2. If no interface is available, consider the abstract base class.Ix. interface takes precedence over reflection mechanism1. Defect of reflection mechanismA, loss of the benefits of compile-time type checkingb, the code needed to perform the reflection access is very clumsy and lengthy.C, Performance loss2, usually only the class must work with the class that is unknown at compile time to need reflection. Used only to instantiate objects, it is best to us

<<effective java>> the best use of combination rather than inheritance

The first thing about using the OO language in Java is that if the class is not designed to be inherited, try not to use the combinationFrom 2, our class B makes a copy of the add of Class A to drink the AddAll method, so that we can count the number of calls to Class A every time we call it, and we actually call Class B.But the count variable of instance object B becomes 2, explaining the reason in Figure 1 I have done a blackboard painting, this exa

"Effective Java" notes

; - } + PublicBuilder Fat (intval) { AFat =Val; at return This; - } - PublicBuilder Sodium (intval) { -Sodium =Val; - return This; - } in Publicnutritionfacts Build () { - return NewNutritionfacts ( This); to } + } - the Privatenutritionfacts (Builder builder) { *Servingsize =builder.servingsize; $Servings =builder.servings;Panax NotoginsengFat =Builder.fat; -Sodium =Builder.sodium; the } +}Call:1 New Nutriti

Effective Java 3

an alternative to choose the following methods:Private Static Final thing[] Private_values = {...}; Public Static Final ListPrivate Static Final thing[] Private_values = {...}; Public Static Final thing[] VALUES () { return private_values.clone ();}9. In Java, public is not the highest access level, and if it is not in the export package, it will be private to the module.10. The public class should not have a public domain unless it is a public

Effective Java within class

Effective Java in the requirements of the class, interface, etc., summed up is enough to do, do not give too much access, the definition of the class is also, if a class is only used inside the class, then the class is defined as an inner class bar.The inner class is divided into four types:1, static inner class: Static inner class is in front of class more static keyword inner class, this class and class s

"Reading notes-effective Java" 02. Consider using the builder when you encounter multiple constructor parameters

construction Process There is a cost to creating the builder //Example Builder mode Public classnutritionfacts {Private Final intServingsize;//Required Parameters Private Final intservings;//Required Parameters Private Final intFat//Optional Parameters Private Final intSodium//Optional Parameters Public Static classBuilder {Private Final intservingsize; Private Final intservings; Private intFat = 0; Private intSodium = 0; PublicBuilder (intServingsize,intservin

Reading notes of "effective Java" Third, strengthen the Singleton property with a private constructor or enumeration type

is asked to create a second instance. In addition to the factory method there is a public domain method:public class Elvis2 {public static final Elvis2 INSTANCE = new Elvis2 ();p rivate Elvis2 () {}public void leavethebuilding () {} }The advantages of this approach are clear and unambiguous. The disadvantage is rigid, performance is not. The advantage of factory method is flexibility. The disadvantage is that it can be easily modified, such as changing to a unique instance of each thread that i

Total Pages: 15 1 .... 6 7 8 9 10 .... 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.