I'm looking through a list of methods and want to identify those that return a primitive (or a primitive wrapper class). Other than a big switch statement is there a simple way to do this?  Method[] methods = fooObj.getClass().getMethods(); for(int i = 0; i &lt; methods.length; i++) {     Method m = methods[i];     Class c = m.getReturnType();     if(c == void.class) {         println("does not return anything.");     }     if( ??? ) {  // &lt;--- what expression to use?         println("a primitive, or primitive wrapper, is returned.");     } }
I have an Object[] array, and I am trying to find the ones that are primitives. I've tried to use Class.isPrimitive(), but it seems I'm doing something wrong:  int i = 3; Object o = i;  System.out.println(o.getClass().getName() + ", " +                    o.getClass().isPrimitive());   prints java.lang.Integer, false.  Is there a right way or some alternative?
Am I eligible for hats if I join a Stack Exchange site after the start of Winter-Bash? How to typeset the symbol “^” (caret/circumflex/hat) I noticed that some Indian languages (eg : Kannada) are not supported in Ubuntu 16.04.  See this screenshot:    Even with file names :    This was not happening in earlier Ubuntu editions. How can I enable kannada in Ubuntu 16.04? Validity of work-energy theorem in presence of non-conservative forces? Log of mounted/unmounted devices in Unix mysql doesn't ask for root password when installing I know roughly and informally what a confidence interval is.  However, I can't seem to wrap my head around one rather important detail:  According to Wikipedia:     A confidence interval does not predict that the true value of the parameter has a particular probability of being in the confidence interval given the data actually obtained.     I've also seen similar points made in several places on this site.  A more correct definition, also from Wikipedia, is:     if confidence intervals are constructed across many separate data analyses of repeated (and possibly different) experiments, the proportion of such intervals that contain the true value of the parameter will approximately match the confidence level   Again, I've seen similar points made in several places on this site.  I don't get it.  If, under repeated experiments, the fraction of computed confidence intervals that contain the true parameter $\theta$ is $(1 - \alpha)$, then how can the probability that $\theta$ is in the confidence interval computed for the actual experiment be anything other than $(1 - \alpha)$?  I'm looking for the following in an answer:   Clarification of the distinction between the incorrect and correct definitions above. A formal, precise definition of a confidence interval that clearly shows why the first definition is wrong. A concrete example of a case where the first definition is spectacularly wrong, even if the underlying model is correct. When I open the file in Vim, I see strange ^M characters.  Unfortunately, the world's favorite search engine does not do well with special characters in queries, so I'm asking here:   What is this ^M character? How could it have got there? How do I get rid of it? Increase the visibility of the association bonus by documenting it with the other privileges What is the sum of the power series: $\sum_{k=2}^\infty\frac{x^k}{k(k-1)}$? What is the function represented by the power series $$ \sum_{k=2}^\infty\frac{x^k}{k(k-1)}\quad? $$  It looks like $\dfrac1{1-x}$ but I don't know. Ubuntu installation does not recognize drive partitioning I have a 1TB drive and installed Windows 7 on a 128GB partition.  When I now try to install Ubuntu 11.04 it does not recognize the Windows partition but offers the complete 1TB drive to install Ubuntu on instead. It displays:    However, in the Ubuntu Disk Utility the Windows partitions are recognized.    What do I need to do in order for Ubuntu to recognize the Windows 7 partition and install Ubuntu as a dual boot?   Response to comments  The following commands were executed and the results are shown below:  fdisk -l  WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk  doesn't support GPT. Use GNU Parted.  Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x34a38165     Device Boot      Start         End      Blocks   Id  System /dev/sda1   *           1          13      102400    7  HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sda2              13       16318   130969600    7  HPFS/NTFS  Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x14a714a6     Device Boot      Start         End      Blocks   Id  System /dev/sdb1               1       60801   488384001   83  Linux   parted -l  Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only. Error: /dev/sr0: unrecognised disk label Review sections to be always in the same place Real life uses of Moment generating functions In most basic probability theory courses your told moment generating functions (m.g.f) are useful for calculating the moments of a random variable. In particular the expectation and variance. Now in most courses the examples they provide for expectation and variance can be solved analytically using the definitions.   Are there any real life examples of distributions where finding the expectation and variance is hard to do analytically and so the use of m.g.f's was needed? I'm asking because I feel like I don't get to see exactly why they are important in the basic courses. Making leaflet control open by default I'm using leaflet to display a map.  I have a control section that I'd like to be open by default, but I can't find a way to do it through the . Is there a way to do this? When I try to connect to servers or join up on lan worlds in Minecraft it says "Failed to Login : Invalid session (Try restarting your game)". Multiplayer used to work fine but now keeps coming up with this error. Can anybody help? How do I use jpnevulator to capture and log the serial traffic between an application and hardware serial port? OK, I've been googling for hours so I obviously have not been able to understand the answers to the various questions that have already been asked about this subject.  I am hoping that, by asking the question again in a more specific way, I will be able to get an answer I can understand.  I have some application running in linux that communicates with an external device attached to a serial port.  I want be able to capture and log the data sent in both directions between the application and the device, with timestamps at the beginning of each line in the file.  As a test case, I am using minicom as the application I want to monitor, connected via a null modem cable to another computer also running minicom.  I have already confirmed that, if I type characters on either of the computers, characters appear in the other computer's terminal.  So far, so good.  I then found this question:    In the answer to this question, the program jpnevulator is suggested.  However, when reviewing the man page, I could not figure out the right way to use jpnevulator to get what I want.  Here is what I tried to do:  First, I opened a terminal window and typed the following command:  $jpnevulator --tty=/dev/ttyS0 --pty --pass --read --ascii --timing-print --file=serial.log   I saw the output:     jpnevulator: slave pts device is /dev/pts/18  I then opened another terminal window and typed the following command:  minicom -D/dev/pts/18 -b115200   Minicom opened without complaint.  However, when I typed characters in either terminal (local and remote), nothing appeared in either terminal.  jpnevulator only logged the data written to /dev/pts/18.  My expectation is that jpnevulator :   reads data from /dev/pts/18 and "passes" this data on to /dev/ttyS0 while also writing this data to the specified file. reads data from /dev/ttyS0 and "passes" this data on to /dev/pts/18 while also writing this data to the specified file.   I am aware of the remark in the faq that says "Jpnevulator was never built to sit in between the kernel and your application. I'm sorry."  However the very same faq states in the second paragraph down: "Now with a little bit of luck some good news: A little while ago Eric Shattow suggested to use pseudo-terminal devices to sit in between the kernel and your application."  That is the approach I am trying to take but I am having no success.  What am I missing?  Thanks to all in advance.  Cheers, Allan  p.s. I was successfully able to capture the back and forth traffic using the socat method mentioned in the existing question I referenced but this method did not offer any way of timestamping the traffic.  I was hoping that jpnevulator would have provided this for me. I'm having some trouble proving that the Gaussian Integer's ring ($\mathbb{Z}[ i ]$) is an Euclidean domain. Here is what i've got so far.  To be a Euclidean domain means that there is a defined application (often called norm) that verifies this two conditions:   $\forall a, b \in \mathbb{Z}[i] \backslash {0} \hspace{2 mm} a \mid b \hspace{2 mm} \rightarrow N(a) \leq N (b)$ $\forall a, b \in \mathbb{Z}[i] \hspace{2 mm} b \neq 0 \rightarrow \exists c,r \in \mathbb{Z}[i] \hspace {2 mm}$ so that $\hspace{2 mm} a = bc + r \hspace{2 mm} \text{and} \hspace{2 mm} (r = 0 \hspace{2 mm} \text{or} \hspace{2 mm} r \neq 0 \hspace{2 mm} N(r) \lt N (b) )$   I have that the application meant to be the "norm" goes: $N(a +b i) = a^2 + b^2$, and I've managed to prove the first condition, given that N is a multiplicative function, but I can not find a way to prove the second condition.   I've search for a similar question but I have not found any so far, please redirect me if there's already a question about this and forgive me for my poor use of latex. Is the empty set a group? Create an instance of an object from a String in Dart? How could the human race be saved in Interstellar? In  (2014) the human race seemed to be facing pretty poor odds until they discovered a convenient wormhole placed by an unknown entity expressed as "they". Later in the movie, we discover that       "they" are actually the human race in the future, reaching back in  time to save itself.   The end of the movie gets a little wild on the physics end, and I'm happy to take that ending as is - no need for it to make sense - but one very basic detail does bother me:  How could the human race have gone back in time to save itself from circumstances that would have caused us to go extinct without our own help (the convenient wormhole)?