SlideShare a Scribd company logo
1 of 24
Java Generics
(Under The Hood Of The Compiler)
By: Harmeet Singh (Taara)
(Java EE Developer)
harmeetsingh.0013@gmail.com
http://harmeetsingh13.blogspot.in
skype: harmeetsingh0013
Contact: Via mail or Skype
Contents
1. Generic Type.
2. WildCards in Generics.
3. Unchecked Warnings.
4. Heap Pollution.
5. Type Eraser.
6. Bridge method.
7. Type Erasure of A Parameterized Type.
8. Type Erasure of A Type Parameter.
9. Type Erasure of A Generic Method.
10.Reficiation.
11.Reifilable Type.
Acknowledgement
● Special Thanks to “Angelika Langer” (Trainer & Author
and Mentor). Everything about generics in this
presentation is get from “Angelika Langer” Generics
FAQ.
info@angelikaLanger.com
Generic Type
● Type Parameter: Is a placeholder that will later be replace but a type
argument.
● A parameterized or generic type is an instantiation of a generic type with
actual argument.
● Define Generics:
class Pair<S,T>{
private S first;
private T second;
-----------------
}
Generic Type
● Types that cannot have type parameter :
o Anonymous Inner Classes
o Exception Types
o Enum Types.
● Generic Type Instantiated:
o Pair<String, Long> pair = new Pair<String, Long>();
● Generics Declarations:
o Collection<String> : Concrete Declaration.
o Collection<?> : Wild Card Declaration.
WildCard in Generics
● We are not create directly object whose types is wildcard parameterized
object
ArrayList<?> list = new ArrayList<?>(); //error
● WildCard parameterized type is not declare in a supertype
class WildCardParam<?>{ //error
---------------------
}
WildCards In Generics
● WildCard Types Family:
o “ ? “ : Unbounded WildCard
o “ ? extends Type ” : WildCard With an upper bound
o “ ? super Type “ : WildCard With an lower bound
WildCards in Generics
● WildCards Bounds: A Reference type that is used to further describe the
family of types denoted by a wildcard.
● Difference between WildCard Bound and Type Parameter Bound:
o A WildCard can have only one bound, while a type parameter can
have several bounds.
o A WildCard can have lower or an upper bound, while there is no such
things as a lower bound for a types parameter.
WildCards In Generics
● Does “extends” always means Inheritance ? : extends is an overloaded
keyword in java. it has different meanings, depending on the context it
appears. The extends keyword appear in four different locations :
o In the Definition of Class.
o In the Definition of Interface.
o In the Definition of Type Parameter bounds.
o In the Definition of WildCards Bounds.
Unchecked Warnings
● Compiler and the runtime system do not have enough type information to
perform all type checks that would be necessary to ensure type safety.
example:
TreeSet set = new TreeSet();
set.add(“abc”); //unchecked warnings.
● Xlint:unchecked enable “unchecked” warnings.
● Xlint:-unchecked and @SuppressWarnings(“unchecked”) disable
“unchecked” warnings.
Heap Pollution
● A Situation where a variable of parameterized types refer to an Object that
is not of that parameterized type.
● Reason of Heap Pollution Occur :-
1. Mixing Raw and Parameterized Type.
2. Unwise Casting.
3. Separate Compilation.
Type Erasure
● How Compiler Translate Java Generics:
○ Compiler translate generic type or method(in any language, not just
java) has in principle two choice.
■ Code Specialization : The compiler generates a new
representation of a generic type of method.
■ Code Sharing : The compiler generates code for only one
representation of a generic type or method and maps all the
instantiations of the generic type of method to the unique
representation , perform type check and type conversion where
needed.
Type Erasure
● What is Type Erasure ?
o The compiler generates only one byte code representation of a
generic type or method and maps all the instantiations of the generic
type or method to the unique representation.
● The type Erasure process can be imagined as a translation from generic
Java Source code back into regular Java Code.
● The Steps performed during type erasure :
o Eliding Type Parameter : When the Compiler finds the definition of a
generic type or method, it removes all occurrences of the type
parameters and replaces them by their leftmost, or type Object if no
bounds specified. Ex: <T> var; into Object var;
Type Erasure
● The Steps performed during type erasure :
o Eliding Type argument: When the compiler finds a parameterized
type, i.e an instantiation of a generic types, then it removes the type
arguments. Like : List<String>, Set<Long> and Map<String, ?> are
translated to List, Set and Map respectively.
Bridge Method
● A Synthetic method that the compiler generates in the course of type
erasure. it is sometimes needed when a type extends or implements a
parameterized class or interface.
Example Before type Erasure:
Bridge Method
Example After type Erasure:
● Side Effect of type erasure is that two methods have identical signature
before type erasure and different signature after type erasure.
Bridge Method
● Under which circumstances is a bridge method generated ?
o Bridge methods are necessary when a class implements a parameterized interface or
extends a parametrized superclass and type erasure changes the arguments type of any
of the inherited non-static method.
Bridge Method
● The compiler must add the bridge methods even if the subclass does not
override the inherited method.
Type Erasure OF Parameterized Type
● The Erasure of a parameterized type is the type without any type argument
(i.e the raw type). The definition extends to arrays and nested types.
Type Erasure Of Type Parameter
● The type erasure of a type parameter is the erasure of its leftmost bound.
The type erasure of an unbounded type parameter is type Object.
Examples :
Type Erasure Of Generic Type
● The Erasure of a method signature consisting of the same name and the
erasures of all the formal method parameters types.
Examples :
Reficiation
● Representing type parameters and arguments of generic types and
method at runtime. Reficiation is the opposite of type Erasure.
Reifiable
● A type whose type information is fully available at run time, that is, a type that does not lose
information in the course of type erasure.
● The following types are reifiable:
o primitive types
o non-generic (or non-parameterized) reference types
o unbounded wildcard instantiations
o raw types
o arrays of any of the above
● The non-reifiable types, which lose type information as a side effect of type erasure, are:
o instantiations of a generic type with at least one concrete type argument
o instantiations of a generic type with at least one bounded wildcard as type argument
● Reifiable types are permitted in some places where non-reifiable types are disallowed.
o as type in an instanceof expression
o as component type of an array
References
● http://www.angelikalanger.com/GenericsFA
Q/JavaGenericsFAQ.html

More Related Content

What's hot

Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCo
Evgeny Mandrikov
 

What's hot (20)

Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
TestingAR XVI - Allure Test Reporting Framework
TestingAR XVI - Allure Test Reporting FrameworkTestingAR XVI - Allure Test Reporting Framework
TestingAR XVI - Allure Test Reporting Framework
 
Java 8 Streams
Java 8 StreamsJava 8 Streams
Java 8 Streams
 
Java threads
Java threadsJava threads
Java threads
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
What is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | EdurekaWhat is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | Edureka
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCo
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Python selenium
Python seleniumPython selenium
Python selenium
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 

Viewers also liked

Viewers also liked (10)

Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
 
Writing beautiful code with Java 8
Writing beautiful code with Java 8Writing beautiful code with Java 8
Writing beautiful code with Java 8
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFuture
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
 
Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To Microsystems
 

Similar to Java generics(Under The Hood Of The Compiler) by Harmeet singh

Similar to Java generics(Under The Hood Of The Compiler) by Harmeet singh (20)

Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
 
2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdf2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdf
 
Generics
GenericsGenerics
Generics
 
Type Systems
Type SystemsType Systems
Type Systems
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Generics
GenericsGenerics
Generics
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programming
 
.Net F# Generic class
.Net F# Generic class.Net F# Generic class
.Net F# Generic class
 
Language tour of dart
Language tour of dartLanguage tour of dart
Language tour of dart
 
Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Type system
Type systemType system
Type system
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
 
Lecture02 java
Lecture02 javaLecture02 java
Lecture02 java
 
TypeScript introduction to scalable javascript application
TypeScript introduction to scalable javascript applicationTypeScript introduction to scalable javascript application
TypeScript introduction to scalable javascript application
 
C# - Igor Ralić
C# - Igor RalićC# - Igor Ralić
C# - Igor Ralić
 
Generics
GenericsGenerics
Generics
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Java generics(Under The Hood Of The Compiler) by Harmeet singh

  • 1. Java Generics (Under The Hood Of The Compiler) By: Harmeet Singh (Taara) (Java EE Developer) harmeetsingh.0013@gmail.com http://harmeetsingh13.blogspot.in skype: harmeetsingh0013 Contact: Via mail or Skype
  • 2. Contents 1. Generic Type. 2. WildCards in Generics. 3. Unchecked Warnings. 4. Heap Pollution. 5. Type Eraser. 6. Bridge method. 7. Type Erasure of A Parameterized Type. 8. Type Erasure of A Type Parameter. 9. Type Erasure of A Generic Method. 10.Reficiation. 11.Reifilable Type.
  • 3. Acknowledgement ● Special Thanks to “Angelika Langer” (Trainer & Author and Mentor). Everything about generics in this presentation is get from “Angelika Langer” Generics FAQ. info@angelikaLanger.com
  • 4. Generic Type ● Type Parameter: Is a placeholder that will later be replace but a type argument. ● A parameterized or generic type is an instantiation of a generic type with actual argument. ● Define Generics: class Pair<S,T>{ private S first; private T second; ----------------- }
  • 5. Generic Type ● Types that cannot have type parameter : o Anonymous Inner Classes o Exception Types o Enum Types. ● Generic Type Instantiated: o Pair<String, Long> pair = new Pair<String, Long>(); ● Generics Declarations: o Collection<String> : Concrete Declaration. o Collection<?> : Wild Card Declaration.
  • 6. WildCard in Generics ● We are not create directly object whose types is wildcard parameterized object ArrayList<?> list = new ArrayList<?>(); //error ● WildCard parameterized type is not declare in a supertype class WildCardParam<?>{ //error --------------------- }
  • 7. WildCards In Generics ● WildCard Types Family: o “ ? “ : Unbounded WildCard o “ ? extends Type ” : WildCard With an upper bound o “ ? super Type “ : WildCard With an lower bound
  • 8. WildCards in Generics ● WildCards Bounds: A Reference type that is used to further describe the family of types denoted by a wildcard. ● Difference between WildCard Bound and Type Parameter Bound: o A WildCard can have only one bound, while a type parameter can have several bounds. o A WildCard can have lower or an upper bound, while there is no such things as a lower bound for a types parameter.
  • 9. WildCards In Generics ● Does “extends” always means Inheritance ? : extends is an overloaded keyword in java. it has different meanings, depending on the context it appears. The extends keyword appear in four different locations : o In the Definition of Class. o In the Definition of Interface. o In the Definition of Type Parameter bounds. o In the Definition of WildCards Bounds.
  • 10. Unchecked Warnings ● Compiler and the runtime system do not have enough type information to perform all type checks that would be necessary to ensure type safety. example: TreeSet set = new TreeSet(); set.add(“abc”); //unchecked warnings. ● Xlint:unchecked enable “unchecked” warnings. ● Xlint:-unchecked and @SuppressWarnings(“unchecked”) disable “unchecked” warnings.
  • 11. Heap Pollution ● A Situation where a variable of parameterized types refer to an Object that is not of that parameterized type. ● Reason of Heap Pollution Occur :- 1. Mixing Raw and Parameterized Type. 2. Unwise Casting. 3. Separate Compilation.
  • 12. Type Erasure ● How Compiler Translate Java Generics: ○ Compiler translate generic type or method(in any language, not just java) has in principle two choice. ■ Code Specialization : The compiler generates a new representation of a generic type of method. ■ Code Sharing : The compiler generates code for only one representation of a generic type or method and maps all the instantiations of the generic type of method to the unique representation , perform type check and type conversion where needed.
  • 13. Type Erasure ● What is Type Erasure ? o The compiler generates only one byte code representation of a generic type or method and maps all the instantiations of the generic type or method to the unique representation. ● The type Erasure process can be imagined as a translation from generic Java Source code back into regular Java Code. ● The Steps performed during type erasure : o Eliding Type Parameter : When the Compiler finds the definition of a generic type or method, it removes all occurrences of the type parameters and replaces them by their leftmost, or type Object if no bounds specified. Ex: <T> var; into Object var;
  • 14. Type Erasure ● The Steps performed during type erasure : o Eliding Type argument: When the compiler finds a parameterized type, i.e an instantiation of a generic types, then it removes the type arguments. Like : List<String>, Set<Long> and Map<String, ?> are translated to List, Set and Map respectively.
  • 15. Bridge Method ● A Synthetic method that the compiler generates in the course of type erasure. it is sometimes needed when a type extends or implements a parameterized class or interface. Example Before type Erasure:
  • 16. Bridge Method Example After type Erasure: ● Side Effect of type erasure is that two methods have identical signature before type erasure and different signature after type erasure.
  • 17. Bridge Method ● Under which circumstances is a bridge method generated ? o Bridge methods are necessary when a class implements a parameterized interface or extends a parametrized superclass and type erasure changes the arguments type of any of the inherited non-static method.
  • 18. Bridge Method ● The compiler must add the bridge methods even if the subclass does not override the inherited method.
  • 19. Type Erasure OF Parameterized Type ● The Erasure of a parameterized type is the type without any type argument (i.e the raw type). The definition extends to arrays and nested types.
  • 20. Type Erasure Of Type Parameter ● The type erasure of a type parameter is the erasure of its leftmost bound. The type erasure of an unbounded type parameter is type Object. Examples :
  • 21. Type Erasure Of Generic Type ● The Erasure of a method signature consisting of the same name and the erasures of all the formal method parameters types. Examples :
  • 22. Reficiation ● Representing type parameters and arguments of generic types and method at runtime. Reficiation is the opposite of type Erasure.
  • 23. Reifiable ● A type whose type information is fully available at run time, that is, a type that does not lose information in the course of type erasure. ● The following types are reifiable: o primitive types o non-generic (or non-parameterized) reference types o unbounded wildcard instantiations o raw types o arrays of any of the above ● The non-reifiable types, which lose type information as a side effect of type erasure, are: o instantiations of a generic type with at least one concrete type argument o instantiations of a generic type with at least one bounded wildcard as type argument ● Reifiable types are permitted in some places where non-reifiable types are disallowed. o as type in an instanceof expression o as component type of an array