Java generic, java generic
I. generic definition1. What is java generics?Generics are new features of Java SE 1.5. The nature of generics is parameterized, that is, the Data Type operated is specified as a parameter.This type of parameter can be
Java Study Notes 10 -- generic summary, java Study Notes 10 -- generic
Java learning notes series:
Java study notes 9-internal class Summary
Java study note 8-interface Summary
Java study notes 7 -- abstract classes and abstract methods
Java study
characteristics of 1.java genericsTypically, a compiler handles generics in two ways:
1.Code Specialization. A new target code (byte code or binary) is generated when instantiating a generic class or generic method. For example, for a generic list,
Brief
Everyone in the ordinary work of study, certainly met many of the following statements:
list
list
As we all know, the above code is about Java generics, so what's the difference between these two different ways of writing?
First, when it
First, IntroductionReview Javac The compilation process of the solution syntax sugar when you see the generic erase in the example, the information on the Internet is mostly more specific, in this make their own some detailed and understandable
The generic type can be used after JDK.A. generic class declaration, such as public class GeneralT B. generic interface declaration, such as public interface GenIntf C. Generic method declaration, as shown in figurePublic void thisIsT (List list,
Java basics-generic 1 and java Basics
The use of generics can make the type name as a parameter in the class or interface definition, just like a common parameter, so that the defined type is more universal.
Advantages of generics:
Strict type
1. ArrayList herolist indicates that this is a Hero generic or its subclass genericThe generics of the herolist may be heroThe generics of the herolist may be ApheroThe generics of the herolist may be AdheroSo it is hard to be sure that the objects
Java generic summary and ApplicationIntroduction:
Before JDK1.5, When you store data into a set, you need to determine whether the type is valid. If you know that you are defining the String type, while you save an Integer data, compilation is
Reproduced from a Sdn-4o4notfoundMany new features have been updated in Spring 4.0, and one of the more important is the support for dependency injection of beans with generics. This change in Spring4 allows the code to use generics for further
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.