How to count mutual words in 2 strings in Java? Say I have two strings:  String s1 = "My name is Alex."  String s2 = "My name is Nick."   I want the program to count mutual words and return the value. With those strings, the returned value would be 3, because of the 3 words both have in common: my, name, is. For some reason, in my program, the num value returned is always 0.  public static int sameWord(String s1, String s2) {      int num = 0;     String[] a = s1.split(" ");     String[] b = s2.split(" ");      for (int i = 0; i &lt; a.length; i++) {          for (int j = 0; j &lt; b.length; j++) {             if (a[i] == b[j]) {                 num++;             }          }     }      return num;  }
How do I compare strings in Java? I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
Annoying FrontEnd bugs in Mathematica 10 I have a burning desire to install RPMs onto my Ubuntu installation - is this possible? Can I use Yum - or another RPM Package Management tool? How to efficiently find positions of duplicates? So, the question pretty much says it all. I'm on Snow Leopard, and I do a lot of web development, particularly in Rails 3 which makes heavy use of the console.  I've seen some notable bloggers etc. mention Zsh as their preference over Bash, but I don't know what difference it would make.  Could anyone give me a good comparison of what difference there is and what might make one prefer one option or the other? What is the exact $SU(2)$ representation to which these Hermitian generators belong? \begin{equation} t_a=\{t_1,t_2,t_3\}=\left\{\frac{1}{\sqrt{2}}\begin{pmatrix}  0 &amp; 1 &amp; 0 \\ 1 &amp; 0 &amp; 1 \\ 0 &amp; 1 &amp; 0 \end{pmatrix},\,\frac{1}{\sqrt{2}}\begin{pmatrix}  0 &amp; -i &amp; 0 \\ i &amp; 0  &amp; -i \\ 0 &amp; i &amp; 0 \end{pmatrix},\,\begin{pmatrix}  1 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; -1  \end{pmatrix} \right\} \end{equation}  I'm a bit puzzled with this, these are not the generators of the triplet representation of $SU(2)$ (the triplet in $SU(2)$ is the adjoint rep which is real and constructed with the structure constants), nevertheless they are used as if they were in much literature. What are really these generators? They seem like the extension to 3 dimensions of the Pauli matrices. The 3 dimensional fundamental rep (this does not make sense to me)? some kind of non-irreducible representation? What is the difference between ++i and i++? In C, what is the difference between using ++i and i++, and which should be used in the incrementation block of a for loop? Display only the penultimate (second last) row of a text Why does the order in which libraries are linked sometimes cause errors in GCC? How to say that the phone is held between shoulder and ear? What are common phrases an English native speaker would use for the pose of speaking on the phone where you use your shoulder to keep the receiver against your ear (and mouth), so your hands are free?  I have some ideas, but they all sound wooden, and I don't think I've ever heard anyone describe this pose in words. It's also pretty much impossible to google for a pose or look it up on leo.org or other dictionaries.  OK, since people keep asking for what phrasings I found, I'll provide two, though I was hoping I could avoid influencing people who answer here by not providing them: "balance on one's shoulder", "held/nestled/sandwiched between shoulder and ear". What are the colored/highlighted edges in edit mode? There are red and pink edges on my mesh.  What do these colored edges mean? How can I use them? How to escape text for regular expression in Java In Windows there’re perhaps only a couple of important folders (by important I mean important in my logical picture of the Windows file system) in the installation drive (in my case C:\). Namely Program Files and Windows. I simply stay away from Windows folder and the “add remove program files” is good enough to handle the program files folder of Windows. Of course there’s a folder named Users where the users (who are not admins) can access only their folders.  Thus there’s a clear picture at some level in my mind of the Windows file system. In Ubuntu, when I reach the location /, there’s a huge list of folders, most of which I have no clue as to what they contain. The /bin folder seems to be the equivalent of the Windows folder in windows. The /usr folder seems like it’s the equivalent of the Users folder in Windows. But even the /home folder looks like it can fit the bill.  Please understand that I do understand, that Ubuntu (Linux) has a different character than that of Windows, i.e., there need not be exact equivalent of Windows functions, in Ubuntu. All I am looking for is a bit more clearer picture of the Ubuntu file system.   This question is a part of a bigger question which I am splitting up to make it more answerable. The original question can be found here: Let $X,Y,Z$ be subspaces of $V$ so that $X$ is a subspace of $Y$. Prove that $Y\cap (X+Z)=X+(Y\cap Z)$ Random piece of plastic Intel HD Graphics 620: Does my display adapter support HDMI 2.0 necessary for a 4k display? I want to connect my laptop (Inspiron 15 5000 Series) to a 4k display. When I read online about this it seems that HDMI 2.0 is a necessaity to handle the large resolutions / refresh rates involved to get full benefits of a 4k display.  Use case: I'm not going to use this to play games. Most of my use-case is editing documents, emails, spreadsheets and some engineering drawings and video (watching not editing).   The goal behind going 4k is to boost productivity by having more things open at once to read side by side.   I looked into the Dell specs and they only mention an HDMI without going into the details of what type or whether it will support HDMI 2.0 / 4K TV.     How do I tell whether my Dell Inspiron Laptop (i7 7500 U processor) supports this?  I looked under the Display Adapters and can see that I have an "Intel HD Graphics 620"  listed.   Will this suffice to tell me if this display adapter will support HDMI 2.0 / 4k display?   Or should I be checking out some other settings?  Thanks! I'm trying to prove that for $p,q&gt;0$, we have $$\int_0^1t^{p-1}(1-t)^{q-1}\,dt=\frac{\Gamma(p)\Gamma(q)}{\Gamma(p+q)}.$$    The hint given suggests that we express $\Gamma(p)\Gamma(q)$ as a double integral, then do a change of variables, but I've been unable thus far to express it as a double integral.  Can anyone get me started or suggest an alternate approach?  Note: This wasn't actually given to me as the $\Gamma$ function, just as a function $f$ satisfying $$f(p)=\int_0^\infty e^{-t}t^{p-1}\,dt$$ for all $p&gt;0$, but I recognized that. This is in the context of an advanced calculus practice exam. Just recently, the right-click context menus in Windows 7 have been acting in a kind of left-handed way. That is, when possible, the initial menu appears to the left of the mouse pointer. When I hover over a submenu option, the next level of context menu appears to the left of the first and so-on.  Basically, what normally happens when you're right at the right-hand edge of the screen is happening all the time - except when I'm at the left-hand edge. Perhaps it's some kind of left-handed users option, but that doesn't seem likely - more like a right-to-left language option, except that I've never even tried to use a right-to-left language.  I haven't checked every app. for the issue - probably only Windows Explorer, definitely not in Firefox, for the moment that's as far as I've checked.  Scratch that - this affects menu bars as well as context menus. The menus dangle down to the left of the menu-bar item instead of the right, and submenus open to the left too. This seems to apply to most applications, but not too Firefox or Thunderbird.  I find this extremely annoying.  I have no idea how this occurred, though it isn't the only weird glitch I've had in Windows 7 in the last few days - see   I assume there's a setting somewhere that has got changed, but I can't find anything. There's also a chance that I've suffered some kind of registry corruption, so I might need to apply a fix in the registry - not something that scares me, but I need to know what to fix and how.  So - does anyone know what setting has been changed, and how I can fix it?  Also, beyond CCleaner (which I already have), are there any tips on making sure that the registry stays clean and sane?  Finally, both Microsoft Security Essentials and Malwarebytes Antimalware seem happy that I don't have a malware problem. Should my recent glitches make me doubt that? Is there a difference between “?!” and “!?”? Sending 2D arrays in Fortran with MPI_Gather How to close/open a view panel I can't find a way to close a view panel, in particular the horizontal at the bottom, is pretty useless to me at this moment.