How to declare a variable according to an unknown List type of the input variable in Java? For example:: You are given arr1, you need to (shallow) copy from arr1 to arr2. But you don't know what type of list arr1 is. This is the code that I use, if I want to declare arr2, I have to go through all possible cases of types of List.   static List&lt;Object&gt; funcOri(List&lt;Object&gt; arr1, List&lt;Object&gt; arr2) {     if (arr1 instanceof ArrayList&lt;?&gt;) {       arr2 = new ArrayList&lt;Object&gt;(arr1);     } else if (arr1 instanceof LinkedList&lt;?&gt;) {       arr2 = new LinkedList&lt;Object&gt;(arr1);     } else if (...) {       ;     }     return arr2;   }  Is there a simpler way to declare arr2 according to the type of arr1 is? Maybe something that simply looks like::   static List&lt;Object&gt; funcWanted(List&lt;Object&gt; arr1, List&lt;Object&gt; arr2) {     arr2 = new XXXList&lt;Object&gt;(arr1); // where XXXList is base on the type of list the arr1 is     return arr2;   }
I have an ArrayList&lt;String&gt; that I'd like to return a copy of.  ArrayList has a clone method which has the following signature:  public Object clone()   After I call this method, how do I cast the returned Object back to ArrayList&lt;String&gt;?
text processing rows to columns for a block I have a file containing lists on Solaris:  List A hi hello hw r u  List B Hi Yes  List C Hello   I need to transpose the lists as shown below:  List A    List B    List C hi        Hi        Hello hello     Yes hw r u   How can I do this on Solaris? How do I remove old kernel versions to clean up the boot menu? Every time I install a new Linux kernel, it gets left in the grub_config, making the boot menu longer each time.    I know I can manually search through the installed packages and remove them.  Does Ubuntu provide any easier way to clean them up or keep them from showing in the boot list? Is Argothian Elder a Druid? is listed on a lot of websites with the Druid creature type, but the card only lists "Elf".  Is Argothian Elder a Druid too? Getting code onto a microcontroller I have broken open a few circuits of some electronics (DVD player, handheld game device) and I can see the microcontrollers in them. However, I have no idea how they get their programs onto them! There is no micro usb or usb plug anywhere on them! How would they have gotten their program onto there? How can I withdraw my paper from a fake conference? How do I resume a release upgrade? Yesterday I started the upgrade from 12.10 to 13.04, but I interrupted it because it was taking too long. Now if I restart it, it doesn't proceed.  Is there any possibility to clean the mess it left when I interrupted it and make a clean restart of this update? I've had a few concerns over a new form of &quot;spam&quot; - that is, through voting. A while back, I had seen some wild reputation increases to my account, amongst others, that seemingly felt weird - as I've barely participated in asking questions or providing answers. Earlier today, this sentiment was echoed by another user in chat:  and like 250 this month? it seems like someone is spam upvoting  This was another user that saw a 250 rep increase, but has been inactive for quite a while. For a site that hasn't seen more than 5 questions a day, that was really weird. To put things even more out of hand, it seems like each vote has been placed on a question.  I did some investigation of my own, and it seems like I've found a badge hunter. More of a... gold badge hunter. This user is among the top 3 voters of the site. Looking into this user's profile, this user only has under 200 rep, and has posted a single question, which was received differently. One thing caught my eye:  Votes all time              by type 581   up              535    question 1     down            47     answer   Each vote is an up vote (with the exception of one), and there are 535 up votes on questions. There are 535 questions in the entire site. Using reputation stats from user profiles, I came with the conclusion that these votes are...  Done within a short period of time. 5 question votes within a couple of minutes Done in [near] perfect chronological order: The earlier the vote, the earlier the question was asked. As if the user had gone through the list of questions in order, and placed an up vote on each one.   I see this as incredibly problematic. First:  It dangerously inflates reputation. Votes are not done based on their content, but simply for voting. Therefore, reputation loses it value as a way to measure expertise.  It's like serial up voting. Generally, when we hear the term &quot;serial up voting&quot;, we think of a voting ring, where one user continuously up votes another. This is negative for the targeted user. Well, here, we've got a voting ring with the site and this user. A user continuously up votes the site, causing negative damage for the site.  We mix good and bad content. Since low quality questions are a victim of the voting spree, many get meddled with the rest of &quot;good quality&quot; questions, despite being closed as off-topic, too broad, or whatever the reason. We can no longer reliably sort questions by quality with the very system that was designed to help us.   ... And the rest of voting fraud issues outlined in .  I've got a couple questions on this:  Is this comparable to serial voting? Should such votes be reversed? How should we determine whether or not to reverse them?  Should we stop this? Let it be? Is this really that big of a problem for sites? (I would argue that it's less of an issue for graduated sites that receive large amounts of content, but what about beta sites that rarely see more than a few questions a day) Order of a product of elements in a generic group I'm dealing with the following question: having a group $G$ (of which nothing else is specified, doesn't have to be abelian), prove that $|ab|=|ba|$ for any $a$, $b$. Since $G$ is not abelian I'm not sure what to use here. I was thinking that except the case where $b=a^{-1}$, the order of those would be $lcm(m,n)$ where $m$ and $n$ are the orders of a and b. But looking it up it seems not to be so simple, even if all the info I could find was for abelian groups, so I would like some help with this specific case. Performance difference between dot notation versus method call in Objective-C With English not being my first language, I usually need support for at least two languages when using features like auto-correct and dictation.  Is it possible to toggle the language which is used for dictation via a shortcut?  As of now, I always have to manually navigate through the menus in the System Preferences which if far from convenient. I've tried to see if there are any pre-defined actions in Automator, but found none. Here's the information :     There are four different pairs of   opening and closing tags which can be   used in PHP. Two of those, &lt;?php ?&gt;   and &lt;script language="php"&gt; &lt;/script&gt;,   are always available. The other two   are short tags and ASP style tags, and   can be turned on and off from the   php.ini configuration file. As such,   while some people find short tags and   ASP style tags convenient, they are   less portable, and generally not   recommended.   In my experience most servers do have short tags enabled. Typing  &lt;?=   is far more convenient than typing  &lt;?php echo    The programmers convenience is an important factor, so why are they not recommended? Why do adult insects have 6 legs? Apparently, there is an advantage to having 6 legs in the insect world. What is that advantage, if anything? Why would such an advantage exist for insects, but not for other, larger land animals?  What do those middle legs do that the front and hind legs cannot, if anything? Are they really essential, or do they just generate more muscle power? Undefined Symbol ___gxx_personality_v0 on link I've been getting this undefined symbol building with this command line:  $ gcc test.cpp Undefined symbols:   "___gxx_personality_v0", referenced from:   etc...   test.cpp is simple and should build fine.  What is the deal? Where do I find out how a command/environment is defined? Say I want to redefine the itemize environment, or make a modified version of it. I want to know how it is currently defined. Where do I find this information? If it's some particular package command, I can just look at the .sty file for that package, but if it's something more basic, I don't know where to look...  Is there a reference manual of where all this stuff is explained? Or is there a file in the depths of my texmf tree I should poke around in? I want to describe my business and want to refer to it in a sentence.  I am trying to say:      "In 2015 we established a business (that is) named X".   Intuitively, the "that is" part is redundant, and makes the sentence more cumbersome. But I cannot think of a reason why we should be able to drop the verb.  Is the version without the "that is" part grammatically correct? How can it be explained? Prove the identity $\binom{2n+1}{0} + \binom{2n+1}{1} + \cdots + \binom{2n+1}{n} = 4^n$ I've worked out a proof, but I was wondering about alternate, possibly more elegant ways to prove the statement. This is my (hopefully correct) proof:  Starting from the identity $2^m = \sum_{k=0}^m \binom{m}{k}$ (easily derived from the binomial theorem), with $m = 2n$:  $2^{2n} = 4^n = \binom{2n}{0} + \binom{2n}{1} + \cdots + \binom{2n}{2n-1} + \binom{2n}{2n}$  Applying the property $\binom{m}{k} = \binom{m}{m-k}$ to the second half of the list of summands in RHS above:  $4^n = \binom{2n}{0} + \binom{2n}{1} + \cdots + \binom{2n}{n-1} + \binom{2n}{n} + \underbrace{\binom{2n}{n-1} +\cdots \binom{2n}{1} + \binom{2n}{0}}_{\binom{m}{k} = \binom{m}{m-k} \text{ has been applied}}$  Rearranging the above sum by alternately taking terms from the front and end of the summand list in RHS above (and introducing the term $\binom{2n}{-1} = 0$ at the beginning just to make explicit the pattern being developed):  $4^n = (\binom{2n}{-1} + \binom{2n}{0}) + (\binom{2n}{0} + \binom{2n}{1}) + \cdots + (\binom{2n}{n-1} + \binom{2n}{n})$  Finally, using the property $\binom{m}{k} + \binom{m}{k-1} = \binom{m+1}{k}$ on the paired summands, we get the desired result:  $4^n = \binom{2n+1}{0} + \binom{2n+1}{1} + \cdots + \binom{2n+1}{n}$ I am new to blender. Pressing &#9096; Ctrl&#9095; AltQ opens the quad view. How to maximize any one of the four views of the quad view? How do you sort du output by size? Show that $\int_{0}^{\pi} xf(\sin(x))\text{d}x = \frac{\pi}{2}\int_{0}^{\pi}f(\sin(x))\text{d}x$ Show that   $$\int_{0}^{\pi} xf(\sin(x))\text{d}x = \frac{\pi}{2}\int_{0}^{\pi}f(\sin(x))\text{d}x$$  this is so confusing. i have no idea how to even start. im thinking integration by parts but that doesnt seem right.  hope you guys can help!! Using ECDSA keys for encryption I know that ECDSA is used for signature only, but I wonder if I can use the public/private Elliptic Curve keys for encryption too.  I have ECDSA SSH public keys and I wonder if I can use them to encrypt data that only the matching machine could decrypt, writing the proper software.  Pointers welcomed.