I have this assignment where I'm supposed to use a custom array list. I am quite confused about lists and generics. In the template for our code we're given "private myObj[] objects;", which is from the class myObj.java which only contains attribute of type T called "data". "private myObj[] objects;" looks a lot like an array to me. I thought generics didn't get along with arrays.  I tried casting to be able to create enough "space" for 10 elements of type T(generic), but I couldn't do this without compiler errors which only go away when I comment out the casting of an array of type myObj of size 10 as "myObj[]". Help me please. My TA's have not answered my questions.
Due to the implementation of Java generics, you can't have code like this:   public class GenSet&lt;E&gt; {     private E a[];      public GenSet() {         a = new E[INITIAL_ARRAY_LENGTH]; // error: generic array creation     } }   How can I implement this while maintaining type safety?  I saw a solution on the Java forums that goes like this:  import java.lang.reflect.Array;  class Stack&lt;T&gt; {     public Stack(Class&lt;T&gt; clazz, int capacity) {         array = (T[])Array.newInstance(clazz, capacity);     }      private final T[] array; }   But I really don't get what's going on.
Book series with a double planet system and poisonous bubbles that float around Forcing a SimpleXML Object to a string, regardless of context How do I add a condition to a query? when upgrading to a 200 amp service panel with service drop coming from bottom underground do I need southern California Edison to come disconnect and then reconnect or can I just do it on my own. I do have a permit. How quickly is the desired state of curl of the Electric Field around a point achieved where a Magnetic Field Vector has just begun changing? My question and context with explanation are given below. Thank you in advance.   Faraday’s Law () states that a time-changing magnetic field vector induces a curl of the Electric field around that point. However it does not specify how quickly the necessary spatial gradient is developed in the Electric Field to satisfy that curl. Of course, the Electric Field vectors around that point cannot just jump to the required values instantaneously in accompaniment as soon as the magnetic field starts changing at a fixed rate, since it is required that the Electric Field has a sensible rate of change to in turn induce a curl of the magnetic Field and continue the propagation of the wave. It would seem the exact rates at which the Electric and Magnetic Fields are changing is critical in the mechanism of an EM wave’s propagation. How would I then calculate the rate of change of E somewhere along the wave given I know the rate of change of the B vector that began it, and given the wave is restricted to one dimension for simplicity? There should after all be some delay in how the EM wave moves from point to point in space, seeing as it moves at the finite speed of causality (3*10^8 m/s), as shown in the first image:    Some of my ideas so far have been that perhaps the rate of change of E is determined such that it exactly cancels the growth of the time-changing E vector that gave rise to a curl of B before, which developed at such a rate to induce a curl of E, which demands this rate of change of E which I am talking about now. In this way the wave might level out the growth of the fields in its wake and spread the change further outwards, in the same way smoothening out a crease spreads it elsewhere. However I am stuck on how to show this rigorously.  I am open to any difficulty of maths, so long as the answer provides the explanation. Below are some diagrams to help visualize what I am talking about:    Faraday's Law requires that a curl of E is developed, which under these restrictions requires a spatial gradient of E to appear across that point. Since the field across that point was previously in some other state, it is required that the Electric Field vectors that are infinitesimally close to that point undergo a rate of change through time to achieve the desired state of curl. The question is, how quickly is this desired state of curl achieved? How could a gap between array modifier created objects be closed? iptables port redirect not working for localhost I want to redirect all traffic from port 443 to the internal port 8080. I'm using this config for iptables:  iptables -t nat -I PREROUTING --source 0/0 --destination 0/0 -p tcp \          --dport 443 -j REDIRECT --to-ports 8080   This works for all external clients. But if I'm trying to access the port 443 from the same maschine I'll get a connection refused error.  wget https://localhost   How can I extend the iptables rule to redirect local traffic too? Where to place log4j.xml So in the documentation for the DescribeFieldResult.getDefaultValue , it says:     Returns the default value for this field   There is a related method called getDefaultValueFormula whose description reads:     Returns the default value specified for this field if a formula is not used.   What is the difference between these methods? I have a field with a default value. When I call getDefaultValue, I get null. When I call getDefaultValueFormula, I get back "This is the default value" (with quotes). I don't understand why getDefaultValue returns null. Story about a trip to a Valley of Sound "Firstly" or "first"? Using The Terminal Command to Shutdown, Restart and Sleep My Mac? I'm getting more interested in using Terminal as an alternative way to address solutions on my Mac. I have seen this question entitled .  I would therefore like to know:  How to shut down, restart and sleep my Mac using the Terminal command exclusively ? I need to amend my return but I already received check from IRS with my refund. Should I cash it out now or wait until I amend my return? I need to amend my return, but I have already received a check from IRS (they approved my return that I need to amend). Should I cash out this check and then amend my return, or should I dispose this check and wait for a check from an amended return? how to stop firing oncomplete if save action has errors My requirement is to stop oncomplete call if save action has errors. I know I am doing some silly mistake.   Here I am unable to stop calling oncomplete function.  Requirement is, from VFP save method, data will get saved and then perform callout from oncomplete function. If there are any errors during save then stop making callouts.  Visualforce  &lt;apex:page id="hasErrorTestPage" controller="ErrorMessageFinder"  showHeader="false"&gt;     &lt;apex:pageMessages id="msgId"/&gt;     &lt;script&gt;         function performCallOutMethod()         {             var msg = document.getElementById('{!$Component.MSEForm.errorMsgInd}').value;             alert(msg);              if(msg == 'false' || typeof(msg) == 'undefined')             {                 alert('entering callout')                 performCallOut();                 return true;             }             else             {                 return false;             }         }     &lt;/script&gt;     &lt;apex:form id="MSEForm"&gt;         &lt;apex:actionFunction name="performCallOut" action="{!submit}" reRender="panelId,msgId"/&gt;          &lt;apex:outputPanel id="panelId"&gt;             &lt;apex:outputText value="{!hasError}" id="errorMsgInd"/&gt;         &lt;/apex:outputPanel&gt;         &lt;apex:inputText id="customerNm" value="{!CustomerName}"/&gt;&lt;br/&gt;         &lt;apex:commandButton value="Save" action="{!save}"                       oncomplete="return performCallOutMethod();" reRender="panelId,msgId"/&gt;     &lt;/apex:form&gt; &lt;/apex:page&gt;   Controller  public class ErrorMessageFinder {     public String CustomerName {get;set;}      public Boolean hasError {          get {              return ApexPages.hasMessages();          }            }      public PageReference save()     {            if(String.isBlank(CustomerName))         {             ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, 'Name cannot be null');             ApexPages.addMessage(msg);             return null;         }         return null;      }       public PageReference submit()     {         try         {   //navigate to view page             PageReference pg = new PageReference('/'+ '0019000001UwnVS');             pg.setRedirect(true);             return pg;         }         catch (Exception ex)         {             System.debug('Error in submit ' + ex);             ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, ex.getMessage());             ApexPages.addMessage(msg);              return null;         }     } }   Based on this code, if I hit save button without entering CustomerName then it is not showing error after save. It is showing error during oncomplete call and then navigating to view page, which I do not want.  Any help is appreciated. I have put a compiled code so that anyone can try with this code. I'm getting these errors ramdomly, and I don't know if its normal or not.   [39441.061856] ata3.00: failed to read SCR 1 (Emask=0x40) [39441.061866] ata3.01: failed to read SCR 1 (Emask=0x40) [39441.061892] ata3.15: exception Emask 0x10 SAct 0x0 SErr 0x280100 action 0x6 frozen [39441.061897] ata3.15: irq_stat 0x08000000, interface fatal error [39441.061904] ata3.15: SError: { UnrecovData 10B8B BadCRC } [39441.061910] ata3.00: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen [39441.061917] ata3.01: exception Emask 0x100 SAct 0xe SErr 0x0 action 0x6 frozen [39441.061923] ata3.01: failed command: READ FPDMA QUEUED [39441.061933] ata3.01: cmd 60/a8:08:b0:48:62/00:00:00:00:00/40 tag 1 ncq 86016 in [39441.061940] ata3.01: status: { DRDY } [39441.061944] ata3.01: failed command: READ FPDMA QUEUED [39441.061953] ata3.01: cmd 60/a8:10:b0:49:62/00:00:00:00:00/40 tag 2 ncq 86016 in [39441.061959] ata3.01: status: { DRDY } [39441.061963] ata3.01: failed command: READ FPDMA QUEUED [39441.061972] ata3.01: cmd 60/58:18:58:4a:62/00:00:00:00:00/40 tag 3 ncq 45056 in [39441.061978] ata3.01: status: { DRDY } [39441.061987] ata3.15: hard resetting link [39441.608302] ata3.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300) [39441.609090] ata3.00: hard resetting link [39441.929246] ata3.00: SATA link up 3.0 Gbps (SStatus 123 SControl 320) [39441.929333] ata3.01: hard resetting link [39442.249184] ata3.01: SATA link up 3.0 Gbps (SStatus 123 SControl 320) [39442.263242] ata3.00: configured for UDMA/133 [39442.277570] ata3.01: configured for UDMA/133 [39442.277725] ata3: EH complete   I'm also pasting smartctl -a for ,  and .  Thanks in advance for your help. How to print colored text to the terminal? How can I output colored text to the terminal in Python? Prove $\sum_{d \leq x} \mu(d)\left\lfloor \frac xd \right\rfloor = 1 $ Taking advantage of one-time pad key reuse? How to remove the “AMD Testing use only” watermark? I've installed the  (beta) following the step in  for Ubuntu Quantal Quetzal. My system is 64 bit and my graphic card is an ATI RadeonHD 6670, this g.c. is Officially Supported (Catalyst &amp; Open Source), you can confirm that from this .  I don't have any problem, except the AMD testing use only watermark. I see the following frame in any stage into the OS (logged, unlloged, etc.) except in the terminals.     I found different versions of how to remove this image, but this change according to the system, so I want an answer from this popular (trusted) site.   How to solve this issue in Ubuntu 12.10 32b? This procedure is different in a 64b system? Why does changing the returned variable in a finally block not change the return value?