Generics

Generics

public class A {
  int i;
  int j;
  void funA()
  {
    i = i+1;
    System.out.println(i);
    j = j+1;
    System.out.println(j);
  }
}

......................................................................

public class Demo<G> {
  G x;
  public static void main(String[] args) {

  Demo<A> d3 = new Demo<A>();
  try
  {
    d3.x.i = 5;//why Null pointer Exception
  }
  catch (Exception e) {
    e.printStackTrace();
  }
 }
}
View Answers

Ads









Related Tutorials/Questions & Answers:
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
Generics
Advertisements
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Generics
Why Generics was introduced in Java?
Why Generics was introduced in Java?  Hi, Why Generics was introduced in Java and what is was its motive? Thanks   Generics were... for compile time type checking. Read the tutorial for more details of Generics
Java Generics
.style1 { list-style-type: square; } Java Generics The Generics.... In general words, Generics allows us to create a single method for sorting... defined types. Generics permits us to catch the incompatible types during
Introduction to Generics in Java
Introduction to Generics in Java: What are the benefits of using Generics in Java? The Generics Features was added to the Java with the release of Java 5.0. The Generics was the long-waited enhancement which is added to the Java 5.0.
When were generics first introduced in Java?
When were generics first introduced in Java?  Hi, I want to know when were generics first introduced in java?   Generics were introduced... the tutorial: Introduction to Generics in Java. Thanks
Wildcards in Generics
Wildcards in Generics In this section, you will learn the use wildcards or wildcard character in Generics. Problem : For better understanding of wildcards... in Generics. Solution : Now, the solution of above problem is : List<?> obj
Generics Example Program in Java
Generics Example Program in Java explaining how you use it effectively? In this section we will explain you how you can use the Generics while writing the Java Program? The introduction to the Generics is the major step in the Java
Generics Method in Java
Generics Method in Java       After going through the example, you will be able to declare... it as return type.         Code for Java Method - Generics
Java generic
to the Java Language including "Java Generics". Using generics makes...? framework is one of the places where Generics are most used. Until the introduction of Generics, when you take an element out of a collection they required
Java Glossary Term - G
Java Glossary Term - G       Java Generic Java 1.5 provides number of new features to the Java Language including "Java Generics". Using generics makes
Advanced Java
Advanced Java   What is the difference between byte code generated between that of Legacy collections and Generics
help needed - Java Interview Questions
help needed  What are the new features added in jdk 1.5?  Hi friend, The following were the new features added in java 1.5. * Generics * Enhanced for loop * Metadata * Static import * Typesafe enums
Advance and Core JAVA Topics
JDBC Under Advanced Java, following topics comes: Generics Reflection
Advanced Java Training
multithreaded programs, using the serialization concepts of java, learn Java Generics... are: Introduction to Generics Type Erasure Type Boundaries Wildcards Generic Methods Strengths and Weaknesses of Generics Legacy Code and Generics Java Thread
Making Enumerations Iterable - JDK 5 Example
;Francis"); sv.addElement("Kabutz"); // using the generics makes...); } // Without generics, we cannot automatically cast to String..., generics makes the code look clumsy // here you should load your own driver
Online Advance Java Training Course
: Introduction to Generics Type Erasure Type Boundaries Wildcards Generic Methods Strengths and Weaknesses of Generics Legacy Code and Generics
Advanced Java Training
Programming language including Generics, Threads, JDBC and Design patterns... java study. Generics - Learn how to use Generics in your Java program Introduction to Generics Type Erasure Type Boundaries
Java Language Specification
are asserts, annotations, generics, autoboxing, enums, static import clauses
How should I start to learn code with Java?
Generics Collections framework Wrappers and Autoboxing IO Streams Thanks  ... Abstract Classes Interfaces Generics Collections framework Wrappers and Autoboxing
java Compilation
check that you're using the collection in a type-safe way, using generics
java Compilation
check that you're using the collection in a type-safe way, using generics

Ads