Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Have Programming Question? Ask it here!

0 Answer(s)      2 years ago
Posted in : Java Beginners

public class A {
  int i;
  int j;
  void funA()
    i = i+1;
    j = j+1;


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

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

View Answers

Related Tutorials/Questions & Answers:
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
generics - Java Beginners
generics  simple notes on Generics as well some programmes, with its... this situation Generics provides a way to communicate the collection type.... Generics provide a mechanism for annotating type information for the use
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
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
Java Notes: Generics
Java Notes: Generics Using predefined generic classes is commmon, writing them is less common. Generics are primarily a way for library authors... static/strong typing and the introduction of generics allows even stronger
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 Iterator
Java Generic Iterator is the new feature added to the jdk1.5. It is used to generalize the Collection classes. It makes the Collection class type safe. It is used with classes, methods and interfaces. Java Generics Iterator
Java arraylist generics example and arraylist generic list
Generics is used to make  the data type safe program. It is the new feature of java 5. When the ArrayList is generalized for a specific data type, other data types cannot be added. It gives error on using the other
Collections Exercise 4 - Word Translator (Generics)
Java: Collections Exercise 4 - Word Translator (Generics) Name ____________________________________ For the purposes of this exercise, the only data structures that need to be considered are: array, ArrayList, LinkedList, HashSet
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
code - Java Beginners
code  Example on exception handling with generics
Advanced Java
Advanced Java   What is the difference between byte code generated between that of Legacy collections and Generics
java - Java Interview Questions
java  What is the purpose of Generics in collection?   Hi I am sending a link where you can find details about generics/collection...;Generics provides a way for you to communicate the type of a collection
JDK 1.5 Features Diff - Java Interview Questions
JDK 1.5 Features Diff   Hi Frieds , Can u explain me d difference bn Generics and Autoboxing in jdk 1.5.  Hi Generics?Provides compile-time type safety for collections
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
Java 5 Features
been extended in two directions. Generics -- Specifying the object type... rewritten in Java 5 using generics Java 5 let's you specify the type of element... that can be. // Same example using generics. List<String> greetings
Java - Java Interview Questions
Java  How to implement Generics Concept in programs?  Hi When you take an element out of a Collection, you must cast it to the type...(); ) if (((String) == 4) i.remove(); } Generics
Self-reloading XML Property Files - Java Tutorials
mentioned that I like generics. To me, they improve the Java language... code with generics quite easy, because IntelliJ IDEA assists me... the cost of initially writing the code. Can generics help
Advanced Java Tutorials
Work the latest JDBC technology Learn Java Generics ADS4ThUnitADS... of your advance java study. Generics Introduction to Generics... Methods Strengths and Weaknesses of Generics Legacy Code and Generics
java - Java Interview Questions
framework better. They also added more features such as Generics, Annotations any many more. Generics made the collection framework to store the objects