Java Best practices

Tuesday, 19 April 2011

Generics : Index or TOC

Generics in java 

Motivation behind Generics-Dealing with casting of objects
The Generics Facility  
Creating a Generic class
Writing a Generic Method

Naming convention in generics
Generics are syntactic sugar - Type Erasure with Generics
Advantage of Generics



Subtyping a generic type

Wildcards in Generics
Generics classes in java vs templates in c++


Some mistakes to be avoided with generics:
Beginner's mistake of using Object as type parameter to make method generic
Generic methods: How generic are generic method?
Wildcards in Generics 
Bounded parametric types 
Covariance, contravariance, invariance
Upper bound boundedness in generics
Lower bound boundedness in generics
Multiple bounds in generics
Get and Set principle in generics
Restrictions on wildcards in generics
Expressing dependencies in type parameters : Wildcards vs type parameters

Class objects as type literals
Generic types are not covariant
Type erasure in generics
Making return type of method as generic
Covariant parameter types
Posted by Rekha Kumari at 05:32
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Generics, java, toc/index, toc2

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Followers

Blog Archive

  • ►  2012 (8)
    • ►  January (8)
  • ▼  2011 (432)
    • ►  December (5)
    • ►  October (3)
    • ►  September (2)
    • ►  July (24)
    • ►  June (61)
    • ►  May (86)
    • ▼  April (120)
      • Exception chaining in java
      • Sorting an array using selection sort (java)
      • Finding smallest and largest number in an array (j...
      • Factorial in java
      • Multiplying 2 matrices in java
      • Immutable Objects / Wrapper Class Caching
      • String equality and interning in java
      • == vs equals method in case of String and primitiv...
      • Value objects or VOs in java
      • equals() for String, StringBuilder and StringBuffer
      • Online java compilers
      • Programming hells you can think off
      • Inner Class Nested Levels In Java
      • Passing by reference doesn't swaps in java
      • Writing a swap function in java
      • Best Way to Swap Values in Java
      • Java timer test
      • Usage of class loaders
      • Getting the class loader of a class
      • What is classloader?
      • Writing custom class loader in java
      • Classloader types
      • Namespaces in class loading
      • Process of Class loading
      • JDBC Hello World program
      • Interview Questions : JEE Web Application Development
      • Lucene In-Memory Text Search Example
      • Batch processing
      • Quartz example
      • Create PDF and RTF reports using Jasper API
      • Playing with JVM heam size
      • Java file as url
      • The InputStream Class
      • What is stream in java IO?
      • Type of Steams in java (reflected in java.io class...
      • Determining the current values of PATH and CLASSPATH
      • Java Tutorial - File IO
      • Path and classpath in java
      • Locale-based or Natural Language based text compar...
      • Significance of searching class path in java
      • Bounding the Parameterized Types
      • Generics : Index or TOC
      • References on generics
      • Points to not about static in java
      • Java memory frames
      • A Java FileFilter example
      • Adding a filter to file chooser dialog
      • How to display all the directories in a directory?
      • How to display all the files in a directory ?
      • Displaying root directories in the system using java
      • Finding the current working directory in java
      • How to traverse a directory in java?
      • How to get the size of a directory in java?
      • How to search all files inside a directory using j...
      • How to get the parent directory of a file in java?
      • How to get the last modification time of a directo...
      • Printing the directory hierarchy in java
      • How to check whether a directory is empty or not?
      • How to delete a directory in java?
      • How to create directories recursively ?
      • Writing generic methods
      • Writing generic class in java
      • Naming convention on generics
      • Generics : Static vs Dynamic typing
      • Making the return type of method as generic
      • Are iterators always fail-safe?
      • Covariance, contravariance and invariance
      • RMI or remote method invocation in java
      • Getting heap memory size in Java program
      • Loading Java Properties Files
      • The clone() method in Java
      • Cloning Interview questions
      • Externalization vs serialization
      • Difference in sizes when you serialize using Seria...
      • What should be done when super class implements th...
      • What will happen when an externalizable class exte...
      • Limitation of serialization
      • Limitation of externalization
      • Using transient keyword in serialization
      • Externalization : The Externalizable interface
      • Java Clone, Shallow Copy and Deep Copy
      • Making your Java Code Privileged?
      • JVM - heap, non heap memory and other terminologies
      • Files-Directory listing in Java
      • Decompile Java Class file using decompilers.
      • Send Email using Java
      • Double Brace Initialization in Java!
      • Why Does A Business Need SOA?
      • Technology Drivers for SOA
      • Service Oriented Architecture – Introduction
      • Different File Read Write Stream Classes in Java
      • When to Say NO to Java
      • Programmatic Compilation with Java
      • Static Imports in Java 5
      • PDF Generation with Big Faceless Report Generator
      • Jfreechart : Charting tools in java
      • Split PDF files in Java using iText JAR
      • iText tutorial:Merge PDF files using iText JAR
      • Setting attributes of PDF using itext
      • Generate PDF as Output Stream in HTTP request usin...
    • ►  March (72)
    • ►  February (57)
    • ►  January (2)
  • ►  2010 (73)
    • ►  December (1)
    • ►  October (24)
    • ►  September (31)
    • ►  August (9)
    • ►  July (2)
    • ►  May (4)
    • ►  April (2)
  • ►  2009 (1)
    • ►  December (1)

About Me

Rekha Kumari
View my complete profile

Labels

  • Access Control (1)
  • awt / abstract window toolkit (1)
  • batch processing (2)
  • Bean (2)
  • bigdecimal (2)
  • BigInteger (1)
  • binding (1)
  • bits (1)
  • bitwise operators (1)
  • books (3)
  • boolean (1)
  • c++ / cpp (1)
  • catalyst (1)
  • character IO (1)
  • charting (1)
  • classloader (13)
  • classpath (5)
  • clone (4)
  • coding style (6)
  • collection-diagrams (2)
  • collection-interface (1)
  • Collections (1)
  • command line arguments (2)
  • command prompt (1)
  • commons-lang (3)
  • commons-logging (1)
  • Comparable (2)
  • Comparator (1)
  • compare() (1)
  • compareTo() (4)
  • Comparison (4)
  • compilers (6)
  • composition (6)
  • compression (4)
  • concatenate (1)
  • conditions (1)
  • Console (1)
  • console input (1)
  • constant / literal pool (4)
  • Constructor (1)
  • contravariance (2)
  • control flow (2)
  • controversy (1)
  • conversion (6)
  • Copy Constructor (1)
  • Copying (3)
  • core-java (2)
  • covariance (5)
  • cpp vs java (4)
  • custom exception (3)
  • cyclic dependency (1)
  • data types (1)
  • dbutils (1)
  • DDD / Domain Driven Design (1)
  • decompile (1)
  • decompiler (1)
  • deep copy (3)
  • delete (1)
  • design (4)
  • design principle (1)
  • destructor (1)
  • deterministic (1)
  • development tools (7)
  • difference (4)
  • directory (16)
  • disadvantage (1)
  • divide-by-zero-exception (1)
  • document (1)
  • double (2)
  • download-source-code (3)
  • dynamic (1)
  • dynamic / weak typing (1)
  • early binding (1)
  • eclipseLink (1)
  • effective java (5)
  • email (1)
  • encapsulation (1)
  • Enum (11)
  • environment variables (1)
  • equality (6)
  • equality operator (1)
  • equals() (10)
  • event (1)
  • example-code (4)
  • excel (1)
  • exception (45)
  • exe (1)
  • executable (1)
  • Execution time (1)
  • externalization (6)
  • failsafe (1)
  • FAQ (1)
  • feed (1)
  • File (3)
  • File handling (30)
  • file IO (3)
  • fileFilter (2)
  • FileFiltername (1)
  • filter (1)
  • Filtered Stream (2)
  • final (3)
  • final classes (1)
  • finalize (1)
  • finally (3)
  • firstProgram / helloworld (7)
  • float (1)
  • formatting output (1)
  • frame (3)
  • Function parameter (1)
  • function pointers (1)
  • Fundamental Prog. Structure (1)
  • gc / garbage collection (4)
  • generic-method (1)
  • Generics (17)
  • generics faciliy (3)
  • getopt (1)
  • Getter (1)
  • GUI (1)
  • guice (1)
  • gzip (1)
  • h2 database (1)
  • hashcode (4)
  • heap-memory (2)
  • hell (1)
  • http (2)
  • httpconnection (1)
  • image (3)
  • immutable objects (3)
  • import (2)
  • in-memory (1)
  • inheritance (10)
  • ini file (1)
  • init block (1)
  • initialization (6)
  • Inner Class (5)
  • Input (1)
  • instanceof (3)
  • integer (2)
  • Interface (1)
  • intern (2)
  • internalization (1)
  • interview questions (7)
  • introduction (1)
  • invariance (1)
  • IO / Input Output (21)
  • ireport (1)
  • isEmpty (1)
  • iterable (1)
  • iterate (1)
  • iterator (2)
  • itext (6)
  • j2ee (1)
  • jar (5)
  • jasper (1)
  • java (506)
  • Java API (1)
  • java console (1)
  • java secret (1)
  • java-practises (8)
  • java-puzzler (1)
  • java-secrets (1)
  • java-tip (1)
  • java.io (31)
  • java.io.File (19)
  • java.lang (3)
  • java.math (1)
  • java.net (2)
  • java.nio (1)
  • java.text (1)
  • java.util.logging (2)
  • java.util.zip (6)
  • Java5 / tiger (4)
  • java6 (1)
  • java7 / jdk7 (8)
  • javac (1)
  • javac options (2)
  • javadoc (2)
  • javamail (2)
  • javax (1)
  • javax.tools (1)
  • jaxb (12)
  • jaxp (1)
  • jdbc (10)
  • jdbc drivers (1)
  • jexcelapi (1)
  • jfreechart (1)
  • jms (1)
  • jpa / java persistence api (15)
  • jsp (1)
  • junit (2)
  • just-in-time (JIT) compilers (1)
  • jvm (8)
  • jython (1)
  • keyword (1)
  • late binding (1)
  • lazy initialization (1)
  • lifecycle (1)
  • limitations (1)
  • list (1)
  • literals (1)
  • locale (1)
  • locking (1)
  • logging (8)
  • lucene (1)
  • main-method (2)
  • map (1)
  • memory (6)
  • memory frame (1)
  • memory leak (2)
  • memory model (2)
  • message-format (1)
  • method overriding / hiding (2)
  • mock test (1)
  • mq / message queue (1)
  • multiple inheritance (1)
  • named exception (2)
  • naming convention (9)
  • nanotime (1)
  • native method (6)
  • natural langauge (1)
  • natural ordering (1)
  • need (1)
  • Nested Class (6)
  • no to constructor (1)
  • non-static (1)
  • NPE / Null Pointer Exception (2)
  • null (4)
  • number (1)
  • NumberFormat (1)
  • numbers (1)
  • object (1)
  • Object class (2)
  • Observable (1)
  • online (1)
  • openjdk (2)
  • operators (7)
  • optimization (1)
  • orm (16)
  • os / operating system (2)
  • output (2)
  • overloading (2)
  • overriding (3)
  • package (3)
  • paradigm (1)
  • parametric type (2)
  • parsing (5)
  • Pass by value (1)
  • password breaking (1)
  • path (2)
  • pdf (4)
  • pdf-generation (5)
  • precompilation (1)
  • preventing inheritance (1)
  • Primary / primitive data types (1)
  • printf (2)
  • privilege (1)
  • process (1)
  • programmatic / runtime compilation (1)
  • programs (10)
  • properties (6)
  • Pros and cos (1)
  • quartz (1)
  • random (2)
  • random stuff (1)
  • raw types (1)
  • read/write (1)
  • recursion (1)
  • regex / regular expression (16)
  • resource (1)
  • restrictions (2)
  • return (1)
  • rmi (4)
  • rss (1)
  • rtf (1)
  • ruby (2)
  • runnable (1)
  • runtime (3)
  • saaj (1)
  • sample code (2)
  • scheduler (2)
  • scjp (7)
  • scope (1)
  • screenshot (1)
  • scripting (1)
  • search (1)
  • security manager (1)
  • sequence diagram (1)
  • serialization (12)
  • server (1)
  • servlet (1)
  • Setter (1)
  • shallow copy (4)
  • slf4j (1)
  • SOA / service oriented architecture (3)
  • soap (2)
  • sort (2)
  • sorting (1)
  • source code (5)
  • split (1)
  • stack (1)
  • stack memory (2)
  • standard IO (2)
  • static (12)
  • static / strong typing (1)
  • static block (1)
  • static initialization (6)
  • Stream (13)
  • String (6)
  • string abnormal (1)
  • string equality (1)
  • string IO (1)
  • string tokenizer (2)
  • String utility (1)
  • substring (1)
  • subtyping (1)
  • swap (4)
  • swing (9)
  • Switch-Case (1)
  • synchronized (1)
  • system properties (2)
  • tdd / test driven development (2)
  • testing (1)
  • thread factory (1)
  • Threads (1)
  • throw (4)
  • throws (4)
  • Time (1)
  • timer (2)
  • TimerTask (1)
  • toc/index (4)
  • toc2 (15)
  • today (3)
  • toString (1)
  • transient (1)
  • traversing (1)
  • try-catch (5)
  • tutorial-References (1)
  • type (1)
  • type parameter (1)
  • type substitution (1)
  • typecast (1)
  • types (1)
  • udf (3)
  • UML (6)
  • underscore (1)
  • unit test (1)
  • unit testing (1)
  • unix / linux (1)
  • URL (2)
  • use cases (1)
  • using reflection (2)
  • utility class (1)
  • validation (1)
  • value classes (5)
  • varargs (2)
  • variance (1)
  • version (1)
Simple theme. Powered by Blogger.