I'm sure I'm missing something very basic, but I can't see what it is.  The following is an excerpt from a larger program that deals hands of cards and determines their rank in poker.  This function turns the first letter in a card string into an integer so that it can be compared.  So, "king of spades" would  send the "k" to this function and it should return 13, "6 of hearts" sends the "6" and gets back 6, etc.  It considers a, k, q, j, and 1 as special cases and then uses Integer.parseInt() on all other inputs.  But, for some reason, it is not ever evaluating the special cases, it is running the else statement every time and crashing on parseInt() when it gets a letter.  All help is appreciated, thank you.      package testSpace;   import java.util.Scanner;   public class main {   public static void main(String[] args) {     Scanner sc=new Scanner(System.in);          System.out.println("Enter a single digit or an a, k, q, or j");         String thisRank = sc.next();        System.out.print(parseRank(thisRank)); }              public static int parseRank(String thisRank){         if(thisRank=="a"){             return 14;         }         else if(thisRank=="j"){             return 11;         }         else if(thisRank=="q"){             return 12;         }         else if(thisRank=="k"){             return 13;         }         else if(thisRank=="1"){             return 10;         }         else{             return Integer.parseInt(thisRank);         }        }      }
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?
It is quite easy to calculate the total number of functions from a set $X$ with $m$ elements to a set $Y$ with $n$ elements ($n^{m}$), and also the total number of injective functions ($n^{\underline{m}}$, denoting the falling factorial). But I am thinking about how to calculate the total number of surjective functions $f\colon X \twoheadrightarrow Y $.  The way I thought of doing this is as follows: firstly, since all $n$ elements of the codomain $Y$ need to be mapped to, you choose any $n$ elements from the $m$ elements of the set $X$ to be mapped one-to-one with the $n$ elements of $Y$. This results in $n!$ possible pairings. But the number of ways of choosing $n$ elements from $m$ elements is $\frac{m!}{(m-n)!\,n!}$, so the total number of ways of matching $n$ elements in $X$ to be one-to-one with the $n$ elements of $Y$ is $\frac{m!}{(m-n)!\,n!} \times n! = \frac{m!}{(m-n)!}$.  Now we have 'covered' the codomain $Y$ with $n$ elements from $X$, the remaining unpaired $m-n$ elements from $X$ can be mapped to any of the elements of $Y$, so there are $n^{m-n}$ ways of doing this. Therefore I think that the total number of surjective functions should be $\frac{m!}{(m-n)!} \, n^{m-n}$.  Is this anything like correct or have I made a major mistake here? Creating an index of quality from multiple variables to enable rank ordering Recursively delete empty directories in Windows Shell script zips a folder, but exclude parameters not working IF its run from cron.daily How do I prove that $$ a^3+b^3+c^3−3abc = 1 $$ if   $ a = 1+\frac{x^3}{3!}+\frac{x^6}{6!}......$ , $b=x+\frac{x^4}{4!}+\frac{x^7}{7!}....$ , $c=\frac{x^2}{2!}+\frac{x^5}{5!}+\frac{x^8}{8!}......$ ?  I have tried the following :-  I discovered that $a+b+c=e^x$ and that $a=\frac{d(b)}{dx}$, $b=\frac{d(c)}{dx}$, $c=\frac{d(a)}{dx}$ . But I am unable to proceed further with these information. Let $$G_\beta(w) = e^{\beta w^2}$$  Now I get the process of applying a fourier transform (or inverse) to get a new  gaussian:  $$G_\beta(x) = G_\beta(0) e^{\frac{-x^2}{4\beta}}$$  but in doing the derivation the constant $G_\beta(0)$ never arose. I know how to calculate the constant, but where did it come from in the derivation?  edit: Fourier form used: $$\int_{-\infty}^{\infty} f(w) e^{-iwx} dw$$ Movie Identification - 1990s VHS Sci-Fi/Horror Should I upgrade to the "mainline" kernels? Newer "mainline" versions of the kernel are available from the , e.g. 3.4 and 3.5, while Ubuntu 12.04 is on 3.2.   What are the mainline kernels? Are they better than my existing kernel? What are the pros and cons of upgrading to a mainline kernel? Will I easily be able to go back? Let $trcA=0$.why $A=M+N$ where $M$ and $N$ are nilpotent matrices? What happens when you run out of movement while jumping? URW-Garamond with mathdesign is typesetting vertical double-quote as vertical double-quote I just started using URW-Garamond with mathdesign, and it's typesetting straight double-quote character as a straight double-quote rather than a right double-quote.  How can I fix this?  That is, when I put this in my header:  \usepackage[T1]{fontenc} \usepackage[urw-garamond]{mathdesign}   I get a nice Garamond in my output, but " in my input file produces a Garamond version of the same character in the output.  If I use two single-quotes instead, it comes out properly as a double right-quote.  I could switch to typing '' or set up a macro, but this is undesirable for more than one reason.  Is there any way to use urw-garamond without this non-traditional behavior for "? If $d(x,y)$ is a metric, then $\frac{d(x,y)}{1 + d(x,y)}$ is also a metric I quite enjoy paying attention to how I design my documents and presentations. I usually spend hours thinking over and designing my slides for a workshop or presentation, so that they are aesthetically pleasing and as intuitive as possible. Likewise I recently started revising my CV I figured and I wanted to make it stand out a bit more. (Just to make it clear I don't mean making a clown of a document but just better use of colors, contrast and design elements.)  I have long wondered whether or not this is something that can backfire, since most documents in academic context are extremely plain, at least in my experience. It's very common to see the default Powerpoint slides (white bg, black arial text) or .   My question is as follows: is putting time and effort into design of academic documents something that can backfire? Will I risk being prejudged with first impressions such as "well he put much effort in the presentation his documents, perhaps because the content is sub-par"?     I realize that the question might be somewhat subjective from person to person but I encourage everyone to consider it in terms of this SE blog entry: . Refer to the "name" of an equation, while a List of Equations is generated using these names Prove that the function $f(x)=\frac{x}{x^2+1}$ is continuous at $x=-1$. Prove  that the function $\displaystyle f(x)=\frac{x}{x^2+1}$ is continuous at $x=-1$. You should give a proof that is directly based on the  definition of continuity.   I saw many similar questions on this website, but none of them gave me a satisfactory answer. I more or less understand how epsilon-delta proofs work but my problem lies more in the algebraic manipulations probably. So here's my "attempt".  Definition of continuity; for $f:A \to \mathbb{R}$     $$\forall \varepsilon &gt;0 \ \exists\delta&gt;0\ \forall x \forall x_0 \in A:|x-x_0|&lt;\delta \Rightarrow |f(x)-f(x_0)|&lt;\varepsilon$$   So from what I understand, the procedure for epsilon-delta proofs are as follows: 1. Plug the point of interest $x_0$ into $|f(x)-f(x_0)|&lt;\varepsilon$ 2. Write $x$ in terms of $\varepsilon$ 3. Then plug $x$ into $|x-x_0|&lt;\delta$ 4. Find $\delta$ in terms of $\varepsilon$. Done    At step 1, we have $\left|\dfrac{x}{x^2+1}+\dfrac{1}{2}\right|&lt;\varepsilon$. Step 2 is where I'm stuck because of the 2nd degree polynomial in the denominator. First, I did this: $\left|\dfrac{x}{x^2+1}\right|&lt;\left|\dfrac{x}{x^2+1}+\dfrac{1}{2}\right|&lt;\varepsilon$. Then, I wasn't too sure about what to do, I thought about getting rid of the "$1$", but that would screw up my inequality. I thought about factoring $x^2+1$, but it doesn't have any real roots. I tried inverting the fraction, but that led me to nowhere. And I've already exhausted the tools I have. How do I proceed?  Apparently, epsilon-delta proofs are the most basic building blocks of analysis. And I'm already failing, this is both embarrassing and depressing... There are two different commands to incorporate another file into the source of some document, \input and \include. When should I use one or the other? What are the differences between them? Are there more things like them to be aware of? Sobolev space $H^s(\mathbb{R}^n)$ is an algebra with $2s>n$ I have a string that represents a non indented XML that I would like to pretty-print. For example:  &lt;root&gt;&lt;node/&gt;&lt;/root&gt;   should become:  &lt;root&gt;   &lt;node/&gt; &lt;/root&gt;   Syntax highlighting is not a requirement. To tackle the problem I first transform the XML to add carriage returns and white spaces and then use a  tag to output the XML. To add new lines and white spaces I wrote the following function:   function formatXml(xml) {     var formatted = '';     var reg = /(&gt;)(&lt;)(\/*)/g;     xml = xml.replace(reg, '$1\r\n$2$3');     var pad = 0;     jQuery.each(xml.split('\r\n'), function(index, node) {         var indent = 0;         if (node.match( /.+&lt;\/\w[^&gt;]*&gt;$/ )) {             indent = 0;         } else if (node.match( /^&lt;\/\w/ )) {             if (pad != 0) {                 pad -= 1;             }         } else if (node.match( /^&lt;\w[^&gt;]*[^\/]&gt;.*$/ )) {             indent = 1;         } else {             indent = 0;         }          var padding = '';         for (var i = 0; i &lt; pad; i++) {             padding += '  ';         }          formatted += padding + node + '\r\n';         pad += indent;     });      return formatted; }   I then call the function like this:  jQuery('pre.formatted-xml').text(formatXml('&lt;root&gt;&lt;node1/&gt;&lt;/root&gt;'));   This works perfectly fine for me but while I was writing the previous function I thought that there must be a better way. So my question is do you know of any better way given an XML string to pretty-print it in an html page? Any javascript frameworks and/or plugins that could do the job are welcome. My only requirement is this to be done on the client side. I was wondering how one can construct a Borel set that doesn't have full measure on any interval of the real line but does have positive measure everywhere.   To be precise, if $\mu$ denotes Lebesgue measure, how would one construct a Borel set $A \subset \mathbb{R}$ such that $$0 &lt; \mu(A \cap I) &lt; \mu(I)$$ for every interval $I$ in $\mathbb{R}$?   Moreover, would such a set necessarily have to contain infinite measure? Create Java console inside a GUI panel How can I create an instance of the Java console inside of a GUI panel?