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




Have Programming Question? Ask it here!
 
 
 


Jagannath
Generics
0 Answer(s)      2 years and a month ago
Posted in : Java Beginners


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();
  }
 }
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
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
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
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.
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
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
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) i.next()).length() == 4) i.remove(); } Generics
Advertisements
 

 

 

DMCA.com