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
Generic is a new function in the C # language and Common Language Runtime Library (CLR) of version 2.0. Generics introduce the concept of type parameters. net Framework, type parameters make it possible to design the following classes and Methods:
Generics: The use of parameterized types to implement multiple data types on the same piece of code. Use the parameterized type to abstract the type for flexible reuse.
Example code:
Class Program
{
static void Main (string[] args)
{
int obj =
C # Generic demonstration
Class Stack {Private T [] store;Private int sizePublic stack (){Store = new T [10];Size = 0;}
Public void push (t x){Store [size ++] = X;}
Public void t POP (){Return store [-- size];}}
Stack X = new stack ();X. Push (17 )
Class Stack {Private T [] store;Private int sizePublic Stack (){Store = new T [10];Size = 0;}
Public void Push (T x){Store [size ++] = x;}
Public void T Pop (){Return store [-- size];}}
Stack x = new Stack ();X. Push (17 );
Generic
18-1, generic-Overview
1. Generic is a new technology in JDK1.5. The emergence of new technologies aims to solve problems.
2. Generics can be used to identify the types of elements stored in a collection.
ArrayList
Al = new ArrayList
();
Generics: The use of parameterized types to implement multiple data types on the same piece of code. Use the parameterized type to abstract the type for flexible reuse.Example code:Class Program{static void Main (string[] args){int obj = 2;test test
Generic and generic sets in C,
1. What is generic?
Generic is a new function in the C # language and the Common Language Runtime Library (CLR). It introduces the concept of type parameters to. NET Framework. Type parameters make it possible to
Feeling for the work of programming, I started to think so, or we are now good. For example, the language developed, developed into easier to understand and programming, tools also developed, programming time is more convenient, such as the current
2005.8.10 Li Jianzhong
Agenda
C # generics and mechanisms
Generic Type
Generic Method
Generic Constraints
Lecture Summary
C # Generic demonstration
We can also directly use the object type. However, due to performance issues and type security
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.