This code is supposed to be able to read a users input and do any of the options in the menu choice, What Im I missing? Sample outputs are   Enter a sample text: We'll continue our quest in space.  You entered: We'll continue our quest in space. MENU c - Number of non-whitespace characters w - Number of words f - Find text r - Replace all !'s s - Shorten spaces q - Quit  Choose an option: c Number of non-whitespace characters: 6     import java.util.Scanner      public class AuthoringAssistant {     public static void main(String [] args) {      Scanner scnr = new Scanner(System.in);     String mainString = "";      System.out.println("Enter a sample text:");     mainString = scnr.nextLine();       System.out.print("You entered: ");     System.out.println(mainString);      return mainString;   }    public static void printMenu(){        Scanner scnr = new Scanner(System.in);        char menuChoice = '?';        String inputString="";        while(menuChoice != 'q'){         System.out.println("MENU");         System.out.println("c - Number of non-whitespace characters");         System.out.println("w - Number of words");         System.out.println("f - Find text");         System.out.println("r - Replace all !'s");         System.out.println("s - Shorten spaces");         System.out.println("q - Quit");          menuChoice = scnr.next().charAt(0);           if(menuChoice == 'c'){             getNumOfNonWSCharacters();           }else if(menuChoice == 'w'){             getNumOfWords();          }else if(menuChoice == 'f'){             findText();          }else if(menuChoice == 'r'){             replaceExclamation();          }else if(menuChoice == 's'){             shortenSpace();         }       }   return;   }  }
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?
Does anyone remember a cartoon with 4-5 humanoid robots on Saturday morning in the mid-80s?  As far as I can remember, they had "powers" to zap things and maybe fly but I don't remember much of the story/plot/enemies/powers.  I don't remember humans in the show.  One scene I remember was the were on some ice world and were being chased by this huge polar kraken type monster.  They got cornered at the edge of this ice sheet and some water.  One of the robots (the leader I guess) asked if someone had any power to do anything.  They all looked at each other and one of the female robots said she did and zapped the ice sheet so they floated away from the kraken.  However, since all of them ran out of power, they couldn't do anything except stand on the ice sheet and float in the water.  I don't remember anything after this scene, probably because my parents shut off the TV, or I'm just that old.  It's also possible I caught the re-runs of it, so it's possible it's late 70s or early 80s. Row colour gaps in tabularx with \aboverulesep and \{} \documentclass[]{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{multicol,booktabs,tabularx}  % Table settings \renewcommand{\aboverulesep}{1pt} \renewcommand{\belowrulesep}{1pt}  \begin{document}     \begin{tabularx}{\textwidth}{@{}X l@{}}         This is Header 1 &amp; This is Header 2 \\         \toprule         \rowcolor{Apricot}         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\         \bottomrule     \end{tabularx} \end{document}   I have the above table MWE using tabularx, and I am trying to colour the row from the table. However, due to the use of my \aboverulesep and \belowrulesep, I now have gaps above and below my table row that is not coloured.   Also, because of the use of my @{} on either side of the table to 'remove' the excess padding on the sides of the table, the row colour is being applied in those padding as well.   Qn 1: How can I colour the aforementioned gaps (arising due to the \aboverulesep) in, while maintaining the rule separation?   Qn 2: How to remove the colour from the two sides of the table?     EDIT  This is in response to Zarko's answer. I want to maintain the use of @{} on either side to remove the padding. If I were to adapt this into your answer, like so:  % @Zarko's answer \documentclass{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{booktabs, cellspace, tabularx}  % Table settings \renewcommand{\aboverulesep}{0pt} \renewcommand{\belowrulesep}{0pt} \setlength\cellspacetoplimit{5pt} \setlength\cellspacebottomlimit{5pt}  \begin{document}     \begin{tabularx}{\textwidth}{@{}SX Sl@{}}% &lt;-- S is append for activate additional vertical space          This is Header 1 &amp; This is Header 2 \\         \toprule         \rowcolor{Apricot}         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\\midrule         This is Text 1 &amp; This is Text 2 \\         \bottomrule     \end{tabularx} \end{document}   I obtain this:   and so my second question (Qn2) is still unresolved.. For Qn 1, I prefer to use the solution by @Skillmon with \renewcommand{\arraystretch}{1.15} as I need not add a new package. Checking for null before event dispatching... thread safe? Something that confuses me, but has never caused any problems... the recommended way to dispatch an event is as follows:  public event EventHandler SomeEvent; ... {     ....     if(SomeEvent!=null)SomeEvent(); }   In a multi-threaded environment, how does this code guarantee that another thread will not alter the invocation list of SomeEvent between the check for null and the invocation of the event? show that  $$\int_{0}^{\infty} \frac {\sin^3(x)}{x^3}dx=\frac{3\pi}{8}$$  using different ways  thanks for all How to plot the first n rows of a table using pgfplots? When using pgfplots, is there a way to plot only the first n rows of a given table ?  Considering the following MWE file:  \documentclass[tikz]{standalone}  \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{amsmath}  \begin{document}      \begin{tikzpicture}         \begin{axis}[%             width=16cm,height=8cm,             view={-45}{65},             scale only axis,             xmin=200,xmax=500,             xlabel={data1},             ymin=0,ymax=100,             ylabel={data2},             zmin=0,zmax=1,             zlabel={data3},         ]         \addplot3 [             thick,smooth,             color= darkgray,             solid]             table[row sep=crcr] {                 250 0 0\\                 250 25 0.2\\                 250 50 0.3\\                 250 75 0.2\\                 250 100 0\\             };          \addplot3 [             thick,smooth,             color= darkgray,             solid]             table[row sep=crcr] {                 450 0 0.5\\                 450 25 0.1\\                 450 50 0\\                 450 75 0.1\\                 450 100 0.5\\             };         \end{axis}     \end{tikzpicture}% \end{document}   How can I plot only the first n=4 rows of each table and ask pgfplots to stop reading the table once this row is reached ?  Of course, for the above example, this seems useless, but when huge data tables are used, this could be extremely usefull, in particular to use the same data and focus on different parts of the table in different figures. Copying and pasting text between applications without style When pasting text, some applications (Chrome, Microsoft Office, etc.) will do what they can to re-render copied text with style, and some of those applications do not appear to offer an option to paste without style.  This results in spending lots of time removing formatting (where it is even possible) and then cleaning up the mess left behind, just to get clean text.  I want to prevent text styling from attaching itself to text that I copy and paste between applications. Is there an OS-level way to do this, i.e. one that can apply to all applications? Failing that, is there a per-application way to tell Chrome, Safari, Word etc. not to copy and/or paste with style? How many solutions for an equation with simple restrictions I'm working on an assignment in which I have to count the number of solutions for this particular equation: $$x_1+x_2+x_3+x_4=20$$for non negative integers with $x_1&lt;8 $ and $x_2&lt;6$   I'm aware that this kind of a task isn't that complicated, but I don't get combinatorics in general that well.  So I've tried two following approaches to get this done.  Firstly I tried to substitute the variable x:  $x_1+x_2+x_3+x_4=20 \Leftrightarrow y_1+y_2+y_3+y_4=34$  in which $y_1=x_1+8$ and $y_2=x_2+6$ (casue $x_1=y_1-8$ and $x_2=y_1-6$) Following this approach the total number of possible solutions would be  $${34+3 \choose 3} $$  But I'm not sure if its the right solution.  The second approach is to sum all of the possible values that $x_1$ and $x_2$ could possibly take, also $x_1=0,1,2,3,4,5,6,7$ and $x_2=0,1,2,3,4,5,6$ And then  count all the possibilities for each of the variables $${20 -x_1-x_2+1\choose 1}$$ and sum them together like this: $${21\choose 1}+{20\choose 1}+{19\choose 1}+{18\choose 1}+... $$ and so on...  I'm sure I'll get the correct number with this one, but I'm not feeling like summing all of this possibilities. There's got to be a better, more elegant way to deal with this.  My professor gave me a hint that I should do it using the complement. Image uploader shouldn't remove unused link references Community♦ user edit: How does it know what to edit? PHP Session Security What are some guidelines for maintaining responsible session security with PHP?  There's information all over the web and it's about time it all landed in one place! Show $d_{1}(x_{n},x)\rightarrow{0}$ if and only if $d_{2}(x_{n},x)\rightarrow{0}$. Let $X=(0,\infty)$. Define two metrics on $X$ by   $d_{1}(x,y)=|x-y|$ and   $d_{2}(x,y)=|x-y|+|\frac{1}{x}-\frac{1}{y}|$   for all $x, y \in{X}$.   Let $(x_{n})$ be a sequence in $X$ and $x\in{X}$.   Show  $d_{1}(x_{n},x)\rightarrow{0}$ if and only if $d_{2}(x_{n},x)\rightarrow{0}$.  Note: $d_{1}$ and $d_{2}$ are then said to be equivalent metrics on $X$.  Since $d_{1}$ and $d_{2}$ are equivalent metrics, will it be sufficient to show $c*d_{2}(x,y)\leq{d_{1}(x,y)}\leq{C*d_{2}(x,y)}$?  So far I have the following: $d_{1}(x,y)=|x-y|\leq{|x-y|+|\frac{1}{x}-\frac{1}{y}|}=d_{2}(x,y)$. Therefore, $d_{1}(x,y)\leq{C*d_{2}(x,y)}$ where $C=1$. Is there a $c$ that would satisfy the left-hand side of the inequality?  Any help would be appreciated. (this is not homework) Gradient Boosting for Linear Regression - why does it not work? Here is my bibliography in latex. The types is "Inprooceedings".  I use WinEdt.    @INPROCEEDINGS{tem_1,   Author         = {Comelli, P, Ferragina, P, Granieri, M.N, and Stabile, F},   Title          = {Optical recognition of motor vehicle license plates},   Year           = {1995},   Volume         = {44},   Series         = {4),   Month          = {November},   Pages          = {790–799},   Publisher      = {Vehicular Technology, IEEE Transactions}    }   But i get this error.   How to solve it? How to make a file executable? How can I make my file so that I can double click on it, and it runs. It is a .sh script, but I also have files that say:  executable (application/x-executable)  in the description of what they are.  I can't run any of these from terminal, or by double clicking.  If possible, I would like a way using either the GUI or a Terminal, but not a combination of the two.  Here is a screenshot of what I see when I right click then go on properties. The file first:    And the shell script here:    NB: I accept that this is a duplicate (I was looking for it, and couldn't find it, so asked + answered it, hoping that I would find it) however, I don't think the question about .desktop files is a duplicate. How can I fix a 404 Error when using a PPA or updating my package lists? PPA seems to be constantly offline. Whenever I use sudo apt-get update, this error is shown:  W: Failed to fetch http://ppa.launchpad.net/ 404  Not Found   How do I fix these errors? What is the meaning of the integral of position? Jerk, $j(t)=\dddot x(t)$, acceleration, $a(t)=\ddot x(t)$ and velocity, $v(t)=\dot x(t)$ are derivatives of position, $x(t)$. What is the meaning of the integral of position?  For example, one could write  $$\int x \mathrm{d}t = \int x \frac{\mathrm{d}t}{\mathrm{d}x}\mathrm{d}x = \int x\frac{1}{v} \mathrm{d}x$$  which reminds the equation for . How do the Hat Dash points work? What made the Ministry admit Sirius was innocent? When $\operatorname{Hom}_{R}(M,N)$ is finitely generated as $\mathbb Z$-module or $R$-module? Assume that $M$ and $N$ are two finitely generated $R$-modules. Then $\operatorname{Hom}_{R}(M,N)$ is a finitely generated $\mathbb Z$-module and/or $R$-module (in this case, assume that $R$ is commutative)?   Note that $R$ is not Noetherian ring. Is there any counterexample (for any cases)? Session ID from scheduled jobs Here's the scenario.  I have a remote application which is invoked from an HTTP callout.  In this callout, I am passing the session ID.  The application can then do its stuff without needing a username and password.  However, I want to be able to invoke the application from a scheduled job, and getsessionid() returns null in this case.  Is there any way around this?  I am trying very hard to avoid storing sfdc usernames and passwords on my remote server, and I want to avoid the hassle of using oAuth with all the complications of client secrets, etc.