0
votes
1answer
59 views
Java generics not complete understanding
Here I have a question regarding Java generics. Assuming we have List data structure in the following forms:
List<Object>
List<?>
List<T>
List<E>
So, what are the ...
2
votes
1answer
53 views
Iterating through elements of a data structure instead of Collection
My problem is this: I have an iterator class which is supposed to iterate through elements in a given data structure, <E> let's say, but what I have managed to accomplish is that when I pass in ...
-4
votes
1answer
25 views
Do jgl.OrderedMap support generics? [on hold]
Just wanted to know. Do objectspace.jgl.OrderedMap support generics?
3
votes
1answer
36 views
JAXB: polymorphism with generics
I'm trying to use JAXB (inside Jersey) for polymorphism with generics:
@XmlRootElement
public class Performance<M extends IMeasurement> {
@XmlAnyElement
private List<M> ...
5
votes
4answers
50 views
Class.asSubclass with multiple bounded types and unchecked cast
I have a class which is generified with the type <T extends Enum<T> & Runnable>. I have a member variable Class<T> bar which I set by the class name: t = (Class<T>) ...
0
votes
4answers
50 views
Clarification about wildcards (Generics) in Java
I have recently started reading Core Java. But I am having a hard time grasping the concept of wildcards.
Specifically, I'm confused about the difference between the following:
public class A<T ...
0
votes
0answers
20 views
Spring Security ACL - @PreAuthorize Generics & Interface
Using Spring ACL with @PreAuthorize annotations on Interfaces which use Generics does not seem to work.
Eg; I have an interface using generics;
public interface MyService<T> {
...
-2
votes
2answers
56 views
Better to use List<Object> or just List [duplicate]
Which would be better in generics? Seems same to me, but eclipse complains to just plain List, but not with List<Object>.
0
votes
1answer
32 views
How to implement Iterator if we don't know the type of the Elements in the Container Type?
I Want to implement an Iterator, but I don't know the type of the Elements of this Container-Type. I just know that my container type is "Ring", and a ring is a Container-Type, with the proprety, that ...
4
votes
4answers
89 views
Detail about the “super” wildcard in java generics
I have a question regarding generics:
Map<? super String, ? super String> mappa1 = new HashMap<Object,Object>();
with super it's possible to instantiate a HashMap<Object,Object> ...
12
votes
2answers
152 views
Does Java fail to deduce the generic type parameter when using the ternary operator (`?`)?
Why is the compiler able to determine the generic type parameter for an
assignment, but not for the ternary operator (?)?
I have a question regarding the compiler being able to deduce the generic ...
0
votes
2answers
57 views
Java Compiler error with multiple generics type
I have a interface like this:
public interface GenericWSEndpoint<T1,T2> {
public void call(String url,String operationName, T1 requestObject, T2 responseObject,long timeout) throws ...
3
votes
4answers
81 views
How to create ArrayList (ArrayList<Integer>) from array (int[]) in Java
I have seen the question: How to create ArrayList (ArrayList<T>) from array (T[])
However when I try that solution with following code, it doesn't quite work in all the cases:
import ...
0
votes
2answers
47 views
Errors while using generics, arrays and compareTo()
I'm trying to write a generic container and I have to use an array. I get the following error :
Exception in thread "main" java.lang.ClassCastException:
[Ljava.lang.Object; cannot be cast to ...
1
vote
2answers
55 views
Interface in generic type in Java
I need to parameterise my class by Enum with some concrete methods, something like:
class K<E extends Enum<E> implements SomeInterface>
But Eclipse prohibit me to use "implements" word ...