Tag: Generics
Posts of Tag: Generics
  1. problem with a HashSet's Iterator

    I'm trying to see if HashSet would be the solution for my next project so i'm doing some very easy test to check functionalities. I have a simple class Klant: public class Klant { private int klantNummer; ...Learn More
  2. How to set a struct value T from Type

    I'm using the extension from Joel's string-to-nullable-type answer here: public static Nullable<T> ToNullable<T>(this string s) where T: struct { Nullable<T> result...Learn More
  3. Why should I replace CollectionBase with Generics?

    I'm not looking for how, I'm looking for why? I couldn't find a straight forward answer to this. ...Learn More
  4. Scala: Handy implicit

    Whenever I get a chance to work in Scala, I always love its simplicity like Python, handiness like Perl, and running like Java. Scala’s implicit ways are another way of writing syntactical sugary flavors of wr...Learn More
    NewsScalaGenericsResultsetScala ImplicitsCamel Case
  5. Java generics, how do you say it when reading code out loud?

    Just wondering, how would you read out loud the following items using generic types? 1) class Box<T> 2) Box<Integer> integerBox 3) class Box<T,U> ...Learn More
  6. Generifying with "super"

    I would like to write an Interator like this: class Plant { } class Tree extends Plant { } class Maple extends Tree { } // Iterator class: compiler error on the word "super". class MyIterator<T super Ma...Learn More
  7. Configuring Checkstyle to ignore generic warnings

    I'm working on a project and using checkstyle to validate the javadocs for the project. I do not want any checkstyle javadoc warnings. However checkstyle is giving me the following unwanted warning to do with ...Learn More
  8. Implementation of Lazy<T> for .NET 3.5

    .NET 4.0 has a nice utility class called System.Lazy that does lazy object initialization. I would like to use this class for a 3.5 project. One time I saw an implementation somewhere in a stackoverflow answer ...Learn More
  9. Java: How to pass a class to a function for instantiation

    Please forgive my ignorance, but I wasn't able to find an answer elsewhere. I have the following code: int value = 5; Strategy s = new Strategy(convert(value)); mainClass.setStuff(s, value); The Strategy is in...Learn More
  10. How to write the constraints for a generic class

    There is a generic class XXValue like this, where the Type T can be value type or reference type, e.g int, string, struct object public class XXValue&lt;T&gt; { public T DefaultValue; } And there i...Learn More
  11. Why does ICollection<T> implement both IEnumerable<T> and IEnumerable

    Why does ICollection<T> implement both IEnumerable<T> and IEnumerable? What is the purpose of this? How does IEnumerable benefit ICollection<T>? ...Learn More
  12. Spring MVC: How to return different type in ResponseEntity body

    In my request handler I want to do some validation and based on the outcome of validation check I will return different response (success/error). So I create a abstract class for the response object and make 2 ...Learn More