I have some Java code similar to:
public class Thing {
private IPolicy policy;
public Thing(IPolicy policy) {
...
|
In Java, why does an untyped invocation of a constructor of parameterised type provoke a compiler warning? Why is it okay to do similar thing with a static method? ... |
Let me describe the situation, and I'm sure I'm just thinking about this problem incorrectly. I have a concrete class that will implement an interface. I want to enforce in the ... |
I am trying to do something I would not normally do, it is a bit odd, but I'd like to make it work. Essentially I have a factory that has ... |
I have a class that needs to use a Class<T> parameter (see my previous semi-related question). It is:
public class BaseTable<T extends TableEntry>
{
protected Class<T> mClass;
...
|
I'm having a hard time wrapping my head around Java generic types. Here's a simple piece of code that in my mind should work, but I'm obviously doing something wrong.
Eclipse reports ... |
I'm having a hard time wrapping my head around Java generic types. Here's a simple piece of code that in my mind should work, but I'm obviously doing something wrong.
Eclipse reports ... |
|
public class Sample<T>{
T data;
Sample(){
data = ????;
}
}
How can i assign a default value to data ?
|
I have a static builder method for a class "Model" that takes a JSON string and returns an ArrayList of Models. I would like it refer to the Model's constructer generically ... |
Say I have a class Foo, a class A and some subclass B of A. Foo accepts A and its sublclasses as the generic type. A and B both require a ... |
Just wonder why type parameter are not allowed after the class name on the constructor. I mean what's the reason behind this. Is it becos' the type parameter already defined on ... |
I have two classes:
public abstract class MyAbstractSuperClass<A, B> {
public MyAbstractSuperClass(Class<A> a, Class<B> b) {
...
}
...
|
I have an interface and a class and both compile just fine.
But when I try to instantiate a Separator with an anonymous implementation of Namer It fails to compile.
private interface Namer<N>
{
...
|
Consider this HashMap extention (generates an instance of the V class when calling "get" if it's null)
public class HashMapSafe<K, V> extends HashMap<K, V> implements Map<K, V>{
private Class<V> ...
|
I just saw this C# question and wondered, if something similar could happen in Java. It can, with
class A<T> {
A(Integer o) {...}
A(T ...
|
I have been searching for quite a while on this, and nothing really comes close to what I need.
Example code:
public class MyQueue<E extends Delayed & Serializable> extends DelayQueue<E> {
...
|
now exists a class below:
class A{
private A(HashMap map){
}
}
how can I get the constructor that the parameters are generics with reflection?
EDIT : ... |
In Java it is tiring to have to write:
Pair<String, String> pair = new Pair<String, String>("one", "two");
It would be nice if the types were inferred for you so you could at least ... |
Here is my problem. I would like to have a class with a private constructor that can be created with more than one static method, exactly like Box.createHorizontalBox(). Where it gets ... |
Any ideas why the code below doesn't compile?
public class A<TT extends B<?>> extends C<TT> implements D<TT> {
protected A(Class<TT> c) {
...
|
I want to develope a class in java. The problem is that the constructor doesn't work
The class is this:
public class EnumSetPlus<E extends Enum<E>> {
//Map
private EnumSet<E> map;
//Constructor
public EnumSetPlus(){
}
I want to inicializate ... |
I was trying to use an inner class of the super type, which was using generics. And got that strange error above.
class MySuperClass<B> {
class InnerClass {
...
|
I have a problem here that still cannot solve, the thing is I have this abstract class:
public abstract class AbstractBean<T> {
private Class<T> entityClass;
public ...
|
I'd have a question here considering java generics.
I have a generic class called LabyrinthImpl with type parameter T. Each instance has a 2D array T[][] values. The problem resides in the ... |
What's the best way to use the PageFactory design with selenium 2 webdriver, but when a page doesn't always load an expected page how can I create the new unexpected page?
public ...
|
public class TreeNode { private E key; private TreeNode[] children; @SuppressWarnings("unchecked") public TreeNode(int numberOfChildren) { children = new TreeNode[numberOfChildren]; // my question is here } public int getNumberOfChildren() { return children.length; } public TreeNode getChild(int childIndex) { return children[childIndex]; } public void setChild(int childIndex, TreeNode child) { children[childIndex] = child; } public E getKey() { return key; } public void setKey(E ... |
In the first code description, please ignore the green commented out code. In the real file this code is not commented out and it is actually functional code in my file. Otherwise the file wouldn't work. i.e. in my ide, this code isn't commented out. Something happened while I was putting it into this forum window. cheers. |
|
|
|