Mockito thenReturn returns null when coming from generic function

I want to mock the ResultSet in a class, whose parameters come from a generic return function (getSQLValue): public class MyClass{ TableClass clsTableClass; public void getResults(Integer …

trouble initialize List Using Arrays.asList

When I initialize List, I am able to do this: List foo = new ArrayList(); foo.add(new Object[]{816, “foo”, 2.6}); But when I want to simplify it using Arrays.asList: List<…

Insert Dimensions to complete Expression/ReferenceType

I’m a newbie to Java. I have provided a short snippet from my code for BFS. public int bfs(Person p, Person q) { private HashMap marked; private int count; marked …

Java Generics With Any Type

I’m trying to write a method in Java that will be able to add a custom Key object to an array, or change an already existing key in the array if there is one. However, I can’t seem to get it to work. …

Generic method to print arrays in java

I am trying to write a generic method printAll which prints an array of integer or character. Here’s the code: public static void main(String[] args) { char cArray[] = {‘a’,’b’,’c’,’d’}; int …

Java override abstract generic method

I have the following code public abstract class Event { public void fire(Object… args) { // tell the event handler that if there are free resources it should call // …

Java generics super keyword

I went through these topics Generics..? Super T Bounding generics with ‘super’ keyword However, I still seem to be kind of lost with super keyword: When we declare a collection like that: List<? …

Get generic type of java.util.List

I have; List stringList = new ArrayList(); List integerList = new ArrayList(); Is there a (easy) way to retrieve the generic type of the …

Get type of a generic parameter in Java with reflection

Is it possible to get the type of a generic parameter? An example: public final class Voodoo { public static void chill(List aListWithTypeSpiderMan) { // Here I’d like to get …