Error in Generics code example

Postby anand.chaubey » Thu Mar 22, 2012 11:45 am

Posts: 1
Joined: Thu Mar 22, 2012 11:34 am
There are few errors in your Java - Generic code example.

Link for the Java Generics is : [b][/b]
Error is as follows :

In the main method you have declared the variables as

Integer[] intArray = { 1, 2, 3, 4, 5 };
Character[] charArray = { 'H', 'E', 'L', 'L', 'O' };

and while accessing you have done like this

System.out.println( "Array integerArray contains:" );
printArray( [b]integerArray [/b]); [b]// pass an Integer array *** This is wrong as no variable with [/b]integerArray

System.out.println( "\nArray characterArray contains:" );
printArray( [b]characterArray [/b]); [b]// pass a Character array *** This is wrong as no variable with characterArrayy[/b]

Please change them to intArray and charArray.


Anand Chaubey

Postby tutorialspoint » Fri Mar 23, 2012 7:06 am

Site Admin
Posts: 143
Joined: Fri Apr 27, 2007 6:52 pm
Thanks dear. This problem has been fixed.