I want to get it to loop at each method/section, but I'm getting errors. When I comment out each do while, they work perfectly, however as a whole I get:     Exception in thread "main" java.lang.StringIndexOutOfBoundsException:   String index out of range: 0 at java.lang.String.charAt(Unknown   Source) at RecursionTester.main(RecursionTester.java:25)   My code:  import java.util.Scanner;  public class RecursionTester {      public static void main(String[] args) {          int power;         int base;         String sentence;         int digit;         int num;         char answer;          Scanner sc = new Scanner(System.in);         do {             System.out.print("What base would you like? ");             base = sc.nextInt();              System.out.print("What power would you like? ");             power = sc.nextInt();              System.out.println(base + " to the " + power + " power is " + raiseToPower(base, power));              System.out.print("\nWould you like raise another number to a power (y or n)? ");             answer = sc.nextLine().charAt(0);         } while (answer == 'Y' || answer == 'y');          do {             System.out.print("Type a sentence and check if it's a palindrome: ");             sentence = sc.nextLine().trim();              if (palindrome(sentence))                 System.out.println(sentence + " is a palindrome");             else                 System.out.println(sentence + " is not a palindrome");              System.out.print("\nWould you like to reverse another text string (y or n)? ");             answer = sc.nextLine().charAt(0);         } while (answer == 'Y' || answer == 'y');         sc.close();     }      //private methods here }
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?
Run a program X times While I'm aware of  it does not quite answer my question. I have a simple sentence:     If any of the devices was not switched off, do something.   Is there supposed to be was or were? I was thinking about was since it could be rephrased as:     If any one of the devices was not switched off, do something.   But maybe that does not make any sense at all. Also, this is for a technical documentation where more formal language is preferred, not sure if that makes any difference. When a word ends in 's' or 'x', do you add 's or just an '? 1) Alex's house      2) Alex' house     When the noun ends with the letter 's' or 'x', do I need to put 's' after an apostrophe or not?  I remember I read some rules related to this in my school grammar book, but now I've forgotten it. How to get the current date/time in Java Show that $\mathbb{Q}(\zeta_n)$ is Galois over $\mathbb{Q}$ and $Gal(\mathbb{Q}(\zeta_n)/\mathbb{Q}))\cong \mathbb{Z_n}^*$ Question 1: For $n \in \mathbb{N}$ explain why $\mathbb{Q}(\zeta_n)$ is Galois over $\mathbb{Q}$   We must show that it is normal and separable.   $\mathbb{Q}(\zeta_n)/\mathbb{Q}$ is normal since it is a splitting field for $X^n-1 \in\mathbb{Q}[X]$ (I think... Is this correct?).  It is separable because it is of characteristic $0$  Question 2: $Gal(\mathbb{Q}(\zeta_n)/\mathbb{Q}))\cong \mathbb{Z_n}^*$  Is this because the primitive nth root of unity $\zeta_n$ acts as a generator for a cyclic group? I am unable to fill out a decent proof on this.   Thanks for your help Can I test if a regex is valid in C# without throwing exception Proof of the following inequality $ \frac{x - y}{\log x - \log y} > \sqrt{xy} $, $x>y$. I have seen the following inequality  $$ \frac{x - y}{\log x - \log y} &gt; \sqrt{xy} \ , \quad \forall x&gt;y $$ be stated as a near "obvious" fact in another , on the site.  The inequality is very cute, but so far I have not been able to prove it.  It reminds me of the Lipschitz inequality, but has some minor differences. Also Jensens inequality comes to mind. Is there something obvious I am missing, or is this ineqality not as easy to prove as it looks? Let us look at some sample data for 5 hypothetical subjects.  library(emmeans) library(lme4)  # generate some sample data # condition (Placebo, Treatment) # type (some factor, e.g. two different medications) # value (outcome of interest) # subject  data &lt;- data.frame(condition = as.factor(rep(c(0,1), times = 10)), value = rnorm(20), type = rep(c("A","B"), each = 10), subject = as.factor(rep(rep(1:5, each = 2), times = 2)))   Now we like to conduct a mixed model and post-hoc tests with emmeans, where we test conditions per type in a pairwise fashion:  # caluculate a mixed model fit_data &lt;- lmer(value ~ condition*type + (1|subject), data = data)  # emmeans post-hoc test emmeans(fit_data, pairwise ~ condition | type)   So for each type (A or B), I have paired data (condition 0 has 5 data points and condition 1 has 5 data points). If I would do a paired t-test like so:  # paired t-test t.test(data[data$condition==0 &amp; data$type=="A","value"], data[data$condition==1 &amp; data$type=="A","value"], paired = TRUE) t.test(data[data$condition==0 &amp; data$type=="B","value"], data[data$condition==1 &amp; data$type=="B","value"], paired = TRUE)   I would get degrees of freedom of 4 for the paired t-test, but emmeans says the degrees of freedom are 12. Why is there this huge difference? If the emmeans package also would use df = 4, then the p-values would also be more comparable. How to run a complete GUI as root? I always thought water sources were called taps in kitchens, bathrooms etc, but a Google search only returned outdoor taps.  So my question is, what are indoor taps really called? Like this one: Is there a way to absolutely force a Log Out, Shut Down, or Restart with open tabs and unsaved documents? I could not find any relatively simple way to log out of a public use Mac quickly with many tabs open and unsaved document in the background without resorting to sudo shutdown -h now.  The reason I ask is that sometimes a user will have his/her account logged into the iMacs here at school and they would try to log off and then leave, thinking it has completed but the process is interrupted by Safari and Office apps, leaving their account, mounts, and websites still accessible to the next person who sits down.  Obviously a shortcut string would be nice instead of posting a note telling the person to type arcane things in a terminal. For example, just having them try to find Terminal.app is going to be a chore.  This doesn't seem to make sense because the user can just quit each app and click a few dialog boxes but unlike you and I to whom repeatedly pounding Command-Q while hitting the spacebar and D keys are probably second nature. What is Skynet's ultimate goal after defeating the resistance? Is it stated in any expanded universe what Skynet's plans were after wiping out the Human race (assuming that was its plan)?  Maybe space travel to colonise different planets or something else entirely? Combining style numeric with style authoryear in BibLaTeX I haven't had a lot of experience with biblatex so far and I decided to use the numeric style for citations in the text. However, the authoryear style for the bibliography is much nicer. I know, I can't actually combine numeric citestyle with authoryear bibstyle.  That brings me to my question: How can I achieve using the numeric citestyle and the formatting of authoryear in the bibliography? Using simple quotes "" instead of \text{} Is there a way to use newcommand or some other nice technique to transform any occurence of  "bla"   in math mode into  \text{bla}   The reason I ask is because it is easy, and doesn't interrupt the flow of reading the (La)TeX code as much.  I would like to keep Xe(La)TeX's nice quote behavior (ie it can use the regular "" instead of backticks to quote some text outside math mode). Brute-force attacking One Time Pads feasible? I have a ciphertext encoded with One Time Pad. I do not know the key. How can I find the possible keys which when decoded, will result in a meaningful plain text? After reading the great answer for  by @Ben, I am a bit confused by the part &quot; set the relative tail sizes as a control variable, and then you find the formula for the length of the confidence interval conditional on that variable&quot;. I understand this means you need to compute the length of the confidence interval as a function of the relative tail sizes and then minimize the function. However, what exactly is relative tail sizes? Is it the ratio between the areas of the two tails? Also, is there another way to find shortest CI for a given confidence level? For those who are interested, I know there are somewhat relevant results allowing us to compute sample size such that the length of a CI, say 95% CI, does not exceed a certain bound. Determine the exact date of creation of an Apple ID Is it possible to determine the exact date and time (if possible) of creation of an Apple ID?   Is there any official or unofficial way to establish this if you don't have the initial sign up information recorded? Can anybody tell me when Application_End is triggered in a lifecycle of an application? When all sessions are ended, will Application_End be triggered automatically? + Are there any other reasons why Application_End could be triggered? Origin of "Fits [x] to a T"? The above phrase is something I've known for as long as I can remember, though I don't know from where. What is its origin and usage? Example: &quot;While Android products aren't quite what I need, iOS devices fit my needs to a T.&quot; show that $\sum_{i=0}^l \dfrac{{l\choose i}}{{n\choose k + i}} = \dfrac{n+1}{(n-l+1) {n-l\choose k}}$ Show that $\displaystyle\sum_{i=0}^l \dfrac{{l\choose i}}{{n\choose k + i}} = \dfrac{n+1}{(n-l+1) {n-l\choose k}}$ for all $k,l, n\geq 0$ with $k+l \leq n.$  The $k+l\leq n$ part doesn't seem that important. The claim clearly holds for $n=0,$ and in that case $k$ and $l$ must both be zero. I think the claim can be shown by induction, but I'm not sure how to do so; I'm not sure how to use the inductive hypothesis to prove the inductive step. The sum on the LHS is not always an integer, so finding a combinatorial argument doesn't seem very feasible. For $n = 1,$ we can have $(k,l) = (0,0), (1,0), (0,1),$ and in each case the sum holds. Perhaps multiplying both sides by a number (idk ${n-l\choose k}$) might be useful?