I have this code:  ObjProcessor processor = getProcessor(); MyClass myObj = getObjToProcess();// MyClass extends PersistentObj   and classes:  public class ObjProcessor {    public &lt;OP extends PersistentObj) void process(Class&lt;OP&gt; objClazz, OP object, Modifier&lt;OP&gt; modifier) {      ...    } } public interface Modifier&lt;T&gt; {     void modify(T obj); }   I am stuck. How do I create an instance of the Modifier to be able to invoke:  processor.process(myObj.getClass(), myObj, ???);     After Ron C's comment, I created this Modifier:   Modifier&lt;MyClass&gt; mod = new Modifier&lt;MyClass&gt;() {     @Override     public void modify(MyClass obj) {        // empty     } };   proc.process(myObj.getClass(), myObj, mod); // compilation error!   Eclipse gave this error:  The method process(Class&lt;OP&gt;, OP, Modifier&lt;OP&gt;) in the type ObjProcessor is not applicable for the arguments (Class&lt; capture#1-of ? extends MyClass&gt;, MyClass, Modifier&lt;MyClass&gt;)
Is it possible to create an instance of a generic type in Java? I'm thinking based on what I've seen that the answer is no (due to type erasure), but I'd be interested if anyone can see something I'm missing:  class SomeContainer&lt;E&gt; {     E createContents()     {         return what???     } }   EDIT: It turns out that  could be used to resolve my issue, but it requires a lot of reflection-based code, as some of the answers below have indicated.  I'll leave this open for a little while to see if anyone comes up with anything dramatically different than Ian Robertson's .
Let $ G $ be an abelian group of order 6.  Then $ G $ has one element of order 6.  And so, $ G $ is cyclic and isomorphic to $ \mathbb Z _6 $.  In general, It is not true that an abelian group of order $n$ has an element of order $n$.  However in the case of $n=6$, it is true. I'm wondering there is any rule of the case (for example, a rule of $n$ that makes an abelian group cyclic). How do you clear a stringstream variable? A better class to update property files? Though java.util.properties allows reading and writing properties file, the writing does not preserve the formatting. Not surprising, because it is not tied to the property file.  Is there a PropertyFile class out there -- or some such -- that preserves comments and blank lines and updates property values in place? Writing string at the same position using Console.Write in C# 2.0 I have a console application project in C# 2.0 that needs to write something to the screen in a while loop. I do not want the screen to scroll because using Console.Write or Console.Writeline method will keep displaying text on console screen incremently and thus it starts scrolling.  I want to have the string written at the same position. How can i do this?  Thanks Quotient rings of Gaussian integers How can I safely prototype a mains power circuit? I'm building a device that has a mains power component, which I need to prototype before building to make sure everything works. I know I need to make sure wiring—and insulation!—is thick enough to cope with the higher current, and that I need to make sure there's enough space between exposed components so there's no arcing. I'll also be stashing whatever I prototype in a nice, insulated box before applying power, and I'll be include a small-value (250mA) fuse just in case. I'll be considering everything double-insulated rather than earthed (plastic enclosure, and there's nothing I'll need to touch while it's operating).  My plan is to solder (through-hole) components directly to each other, then insulate everything (with heatshrink tubing or electrical tape) as much as possible, then use screw-type cable joiners to connect the power cable.  I know I can't use traditional prototyping tools such as breadboards and stripboard for mains voltages, but what can I use to make prototyping at mains voltages easier?  (To be clear, 'mains voltage' in my area means 230V AC +10/-6% at 50Hz; GPOs are generally rated at 10A.) A question about long exact sequence of finite dim vector spaces Q) Prove that if $0\rightarrow V_1\rightarrow V_2\rightarrow...\rightarrow V_k\rightarrow 0$ is an exact sequence of finite dimensional vector spaces, then $\sum_{i=1}^{k}(-1)^idim (V_i) = 0$.  For $k=3$, I see that the statement is true. For $k&gt;3$, am I correct in understanding that $V_2 = V_1\oplus V_3 (\implies dim(V_2)=dim(V_1)+dim(V_3))$ and $V_3 = V_2\oplus V_4(\implies dim(V_3)=dim(V_2)+dim(V_4))$ and so on?   If it is true, then for $k=4$, $\sum_{i=1}^{4}(-1)^idim (V_i) = -m_1+m_1+m_3-m_2-m_4+m_4$ and am not sure why $m_2=m_3$ for the sum to be $0$? where $m_i = dim(V_i)$. Thanks. Physics are not simulated past a certain frame? I wasn't aware of a difference, but a coworker says there is, although he can't back it up. What's the difference if any? Space ship manned by only AI returns home to a different earth, back in time Continuously invertible operators How do we solve (i.e. get the closed form of) $\int \sqrt{1 + t^2} dt$ ?   shows the closed form of it but not the steps in solving it.  I think I need some algebraic trick..   I thought of some hyperbolic functions and their derivatives and equalities:  If I make $ t = \sinh x$, then I can reduce the integral to  $$ \int \cosh ^2 x dx $$ though I'm not sure if this is valid. But from here, I cannot go on evaluating the integral... fastest way to detect if a value is in a group of values in Javascript I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.  What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?  I think if I keep the values sorted and do a binary search, it should work fast enough. Or is there some other smart way of doing this, which can work faster? Continuous function from $(0, 1]$ onto $(0, 1)$? Clarify or visualize the parameters involved for receiving the Curious badge image of polynomial map is not an algebraic set I am doing an exercise about algebraic geometry, where the exercise  tell us to provide example of the image of polynomial map $f:\mathbb{C}^{m}\rightarrow \mathbb{C}^{n}$ that is not an algebraic set. But I am thinking that the image of every polynomial is $\mathbb{C}$ thus every polynomial map is surjective. What have I misunderstand? Get last result in interactive Python shell How can I improve Ubuntu overall system performance? What are your tips for improving overall system performance on ubuntu? Inspired by this  I realized that some default settings may be rather conservative on Ubuntu and that it's possible to tweak it with little or no risk if you wish to make it faster.  This is not meant to be application specific (e.g. make firefox load pages faster), but system wide.  Preferably 1 tip per answer, with enough detail for people to implement it.  A couple of mine would be:   Install  (via Software Center or sudo apt-get install preload); Change  value - "which controls the degree to which the kernel prefers to swap when it tries to free memory";   What are yours?  PS: Since this is not intended to have a unique answer but rather, several useful tips, I'm making this community wiki out-of-the-box. Example of a Borel set that is neither $F_\sigma$ nor $G_\delta$ I'm looking for subset $A$ of $\mathbb R$ such that $A$ is a Borel set but $A$ is neither $F_\sigma$ nor $G_\delta$. The moderator agreement is visible at the following URL:       I acknowledge and agree that as a moderator for Stack Exchange Inc.      I will abide by the then-current Terms of Service of Meta Stack   Exchange, and other moderator policies made available to me,      I acknowledge that I may have access to potentially   personally-identifying information about Meta Stack Exchange users and   that in connection with such access      I will use such information solely in accordance with the then-current   Privacy Policy of Meta Stack Exchange,      I will not disclose this information to anyone,      I will not store or copy this information and      I will only use such information in connection with performance as a   Meta Stack Exchange moderator for the benefit of Meta Stack Exchange.      I acknowledge and agree that I am an independent volunteer moderator   to Meta Stack Exchange and I am not an employee, agent or   representative of Stack Exchange Inc., and I have no authority to bind   Stack Exchange Inc. in any manner. Stack Exchange Inc. reserves the   right to terminate my privileges as a moderator at any time without   warning.   It hasn't been updated with the new company name and still refers to Stack Exchange Inc. instead of Stack Overflow (Inc.?).