If you have an instance of a Collection, say something like:  Collection&lt;String&gt; addresses = new ArrayList&lt;String&gt;();   Which were to then be populated with a bunch of values, which is the "best" way, if any, to make use of the toArray() method without requiring a type cast?  String[] addressesArray = addresses.toArray(new String[] {}); String[] addressesArray = addresses.toArray(new String[0]); String[] addressesArray = addresses.toArray(new String[addresses.size()]); String[] addressesArray = addresses.toArray(new String[addresses.size() + 5]);   Is there any semantic difference between the first two? Is the third most efficient? Is the fourth less efficient than the third?
Assuming I have an ArrayList  ArrayList&lt;MyClass&gt; myList;   And I want to call toArray, is there a performance reason to use  MyClass[] arr = myList.toArray(new MyClass[myList.size()]);   over  MyClass[] arr = myList.toArray(new MyClass[0]);   ?  I prefer the second style, since it's less verbose, and I assumed that the compiler will make sure the empty array doesn't really get created, but I've been wondering if that's true.  Of course, in 99% of the cases it doesn't make a difference one way or the other, but I'd like to keep a consistent style between my normal code and my optimized inner loops...
How to concatenate text from multiple rows into a single text string in SQL server? Prove that any complex matrix can be expressed in term of Hermitian and anti-Hermitian matrices How can we prove that any complex matrix can be expressed in term of hermitian and anti-hermitian matrices of the following form $A = H_1 + iH_2$ Where, $H_1$ is hermitian and $H_2$ is an anti-hermitian matrix Exeception on After Insert, Record is read only I'm writing a trigger for new opportunity products to populate  a field Product_Category__c (on opportunity lineitem) getting the value from Product_Category_new__c (on Product).  This is my trigger:  trigger SetProductCategory on OpportunityLineItem (after insert) {      for (OpportunityLineItem opplineitem: Trigger.new) {                    opplineitem.Product_Category__c =  opplineitem.PricebookEntry.Product2.Product_Category_new__c;     }      }   I get this error message:     execution of AfterInsert caused by: System.FinalException: Record is read-only   I have tried with before insert;in this case there aren't errors but the value Product category it's not saved on Opportunity Line item.  I have found that:  In a after insert trigger is not allowed change field using trigger.new  Please can you suggest a solution for this? i would like to copy the value Product category (Product) on Product Category (Opportunity Product)  after the insert of the new opportunity products.  Thanks in advantage for any advice.  Br How to install driver for TP-Link TL-WN722N(EU)V2 on Ubuntu 17.04 Kylin I can not install the TP-LINK WN722N V2, which includes a 8188 EUS chip. Then I tried to install the backports v4.4.2,but   do not want to recognize either.  The TP-Link driver installation errors thrown out:  man@kman-livve:~$ cd '/home/kman/Documents/Tplink 722 N V2/rtl8188EUS_linux_v4.3.0.8_13968.20150417' kman@kman-livve:~/Documents/Tplink ...$ sudo make  "******************************************" "NO SKRC,we will use default KSRC" "******************************************" make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/4.10.0-15-generic/build M=/home/kman/Documents/Tplink 722 N V2/rtl8188EUS_linux_v4.3.0.8_13968.20150417  modules make[1]: Entering directory '/usr/src/linux-headers-4.10.0-15-generic' arch/x86/Makefile:140: CONFIG_X86_X32 enabled but no binutils support make[1]: *** No rule to make target '722'.  Stop. make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-15-generic' Makefile:1367: recipe for target 'modules' failed   A method to know him, I do not know about. Thanks  Model:TL-WN722N(EU)_V2_161112_Linux.zip Chipset:rtl8188EUS_linux_v4.3.0.8_13 Is there a way to add some custom font on a website without using images,  or some other graphics?  For example, I was working on a wedding website, and I found a lot of nice fonts for that subject. But I can't find the right way to add that font on the server. And how do I include that font with CSS into the HTML? Is this possible to do without graphics? How to fix pagination for custom loops? How do I install an application from a .dmg disk image? I've downloaded Firefox and it's now sitting on my desktop as Firefox.dmg. When I double click on Firefox.dmg it opens up a window with Firefox in it so I can use it - does this mean the application has been installed?    Community Wiki'd the question because I think it's a worthwhile question to have on the site for pointing people to, it's not exactly intuitive to do and not a question I think I deserve any rep from. R linear regression categorical variable "hidden" value What is the purpose of using a FIFO vs a temporary file or a pipe? Why is there an extra plastic container in my toilet tank? Let $A$ , $B$ be topological spaces such that there for some subset $D$ of $B$ there is a homeomorphism form $A$ to $D$ and for some subset $E$ of $A$ there is a homeomorphism form $B$ to $E$ ; then must there exist a homeomorphism from $A$ to $B$ ? getResourceAsStream() is always returning null Strange, unexpected behavior (disappearing/changing values) when using Hash default value, e.g. Hash.new([]) bcmwl-kernel-source broken on kernel: 5.8.0-34-generic I am unable to cover the following class get set method. Need help in creating test class  public class Aresult{      public class Parent {         public String type {get; set;}         public String id {get; set;}         public String sequence_id {get; set;}         public String etag {get; set;}         public String name {get; set;}     } }   Please suggest  @isTest  public class CirriusGetItemsResultTest {     public static void myUnitTest(){         Aresult.parent a = new Aresult.parent();         a.type='hello';         a.id='hello';         a.sequence_id ='hello';         a.etag ='hello';         a.name ='hello';     } } what could cause a script to fail to find python when it has `#!/usr/bin/env python` in the first line? Trying to get casperjs running on Ubuntu 12.04. After installing it when I run I get:   09:20 $ ll /usr/local/bin/casperjs lrwxrwxrwx 1 root root 26 Nov  6 16:49 /usr/local/bin/casperjs -&gt; /opt/casperjs/bin/casperjs  09:20 $ /usr/bin/env python --version Python 2.7.3  09:20 $ cat /opt/casperjs/bin/casperjs | head -4  #!/usr/bin/env python  import os import sys  09:20 $ casperjs : No such file or directory  09: 22 $ python Python 2.7.3 (default, Sep 26 2013, 20:03:06)  [GCC 4.6.3] on linux2   So Python is present and runnable, casperjs is pointing to the right place and it is a python script. But when I run it I get "No such file".   I can fix it by changing the first line of the casperjs python file from:    #!/usr/bin/env python   to:   #!/usr/bin/python   Result:   $ casperjs --version 1.1.0-DEV   I managed to fix it, but I'm wondering why it didn't work with #!/usr/bin/env python, since that seems to be a normal interpreter line. Do I have something configured wrong?   Here are the steps to get casperjs:   $ git clone git://github.com/n1k0/casperjs.git $ cd casperjs $ ln -sf `pwd`/bin/casperjs /usr/local/bin/casperjs $ casperjs : No such file or directory Removing the password from a PDF file I have a couple of ebooks as PDFs with passwords, however my ebook reader (sony prs600) doesn't seem to support PDFs with passwords.  What is the easiest of removing the password from a PDF (I know the password, which presumably helps a lot).  It's a bit annoying buying a book and then only being able to read it in front of a computer. I'm using this code to get standard output from an external program:  &gt;&gt;&gt; from subprocess import * &gt;&gt;&gt; command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]   The communicate() method returns an array of bytes:  &gt;&gt;&gt; command_stdout b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file2\n'   However, I'd like to work with the output as a normal Python string. So that I could print it like this:  &gt;&gt;&gt; print(command_stdout) -rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file1 -rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file2   I thought that's what the  method is for, but when I tried it, I got the same byte array again:  &gt;&gt;&gt; binascii.b2a_qp(command_stdout) b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0 Mar  3 07:03 file2\n'   How do I convert the bytes value back to string? I mean, using the "batteries" instead of doing it manually. And I'd like it to be OK with Python&nbsp;3. Mapping Russia - Int'l dateline splitting polygon Any point to downvoting already closed questions? That question of mine was closed a long time ago (relatively, to me at least).  However, from time to time I still get downvotes for it.  That got me thinking: is there any reason to still downvote closed questions?