Hey guys I've been having trouble with my code within the if statements. Regardless of what I enter the if statements always return f_resist [] to 0. I think there is an error along my if statements but im not sure :(  Scanner u_scancolor = new Scanner(System.in); //declare input box System.out.println("Enter three colors on the resistor seperated by hyphens.      ie: Red-Blue-Brown"); System.out.println("Colours you can use: Black, Brown, Red, White, Orange,   Yellow, Green, Grey, Violet, Blue"); String f_wire = u_scancolor.next(); //takes a string System.out.println(f_wire); int [] f_resist; f_resist = new int [3];   String [] f_wordcolor= f_wire.split("-"); //splits the colors by hyphen into   individual strings   for (int cnt1=0 ; cnt1&lt;3; cnt1++) {   f_wordcolor [cnt1] = f_wordcolor [cnt1].toUpperCase();  System.out.println(f_wordcolor [cnt1]);  if (f_wordcolor [cnt1] == "BLACK ") {    f_resist [cnt1] = 0;   }  else if (f_wordcolor [cnt1] == "BROWN") {    f_resist [cnt1] = 1;  }    else if (f_wordcolor [cnt1] == "RED") {    f_resist [cnt1] = 2;   }   else if (f_wordcolor [cnt1] == "ORANGE") {    f_resist [cnt1] = 3;   }  else if (f_wordcolor [cnt1] == "YELLOW") {    f_resist [cnt1] = 4;   }  else if (f_wordcolor [cnt1] == "GREEN") {    f_resist [cnt1] = 5;  }   else if (f_wordcolor [cnt1] == "BLUE") {    f_resist [cnt1] = 6;   }    else if (f_wordcolor [cnt1] == "VIOLET") {    f_resist [cnt1] = 7;   }    else if (f_wordcolor [cnt1] == "GREY") {    f_resist [cnt1] = 8;   }    else if (f_wordcolor [cnt1] == "WHITE") {    f_resist [cnt1] = 9;   }    System.out.println(f_resist [cnt1]);  }  String f_add1 = Integer.toString(f_resist [0]); String f_add2 = Integer.toString(f_resist [1]); String f_stringadd = f_add1 + f_add2;  int f_intadd = Integer.parseInt(f_stringadd);   int f_ohm = f_intadd*10^f_resist[2];  System.out.println("Total ohms: " + f_ohm);  } }
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?
Grouping functions (tapply, by, aggregate) and the *apply family Vote to close a deleted question - bug? I just successfully added my Close vote to a question on Stack Overflow that had already been deleted by the author.  The question can be found .        The only purpose I see for such functionality is perhaps to stop someone from escaping the initial surge of wrath from critics, then subsequently undeleting their question.  And that would be a pretty strange thing to guard against.  It seems far more likely that this is an oddity that was overlooked.  So I'm just curious - is voting to close a deleted question a bug, or is it ?  If by design, what is the rationale behind it? How many injective functions $f:[1,...,m]\to{[1,...,n]}$ has no fixed point? $(m\le n)$ Fixing scrolling in nano running in tmux in mate-terminal The problem:   I open a terminal (in Linux Mint, so mate-terminal) zsh is the shell Then I run tmux Edit a file with nano Scroll up and down that file with the cursor Issue: When scrolling down in nano, only the bottom half of the terminal window gets refreshed Issue: When scrolling up in nano, only the top half of the terminal windo gets refreshed   The complete nano view of file does not get refreshed in my terminal window when scrolling. Any tips?  Edit: my .tmux.conf  It seems that this line specifically is the culprit (as commenting it out fixes the problem):  set -g default-terminal "xterm-256color"   I'm pretty sure I added that line because I have issues even running nano during an SSH session.  Here is the full file:  set-option -g default-shell /bin/zsh  # Make sure tmux knows we're using 256 colours, for # correct colourised output set -g default-terminal "xterm-256color"  # The following were marked as "unknown", so # I do know what I'm doing wrong. #set -g mode-mouse on #setw -g mouse-select-window on #setw -g mouse-select-pane on  # Attempting to stop "alert" sound upon startup # but none of these are working... set-option bell-on-alert off set-option bell-action none set-option visual-bell off Is there a non written rule to which person to use in the PhD thesis, 5 years of using "We" in the papers have brought me to the innate necessity to do it every time I describe something.  Recently, though, one of my lab-mates told me that I should use I, since it is your work, if the thesis were co-written, then it would be a different story.  Is there any standard in your universities, or do you have any preferred practice. Proof a graph is bipartite if and only if it contains no odd cycles How can we prove that a graph is bipartite if and only if all of its cycles have even order? Also, does this theorem have a common name? I found it in a maths Olympiad toolbox. How do I set a background image while I am editing? The shrine indicator (shrine detector? GPShrine?) has both visual and audio cues, so when I'm near a shrine, it beeps constantly. Unfortunately, I occasionally play the game near other humans who are engaged in their own activities, and my wife is decidedly unimpressed with this feature.   When I got the shrine indicator, I could have sworn that the dialogue said I could press [Y] to disable it... but pressing Y pulls out my weapon.   Ideally, I'd like to just make it stop beeping, but stay on for visual cues. But I'll settle for being able to turn it off entirely at times. Export nodes from Drupal 4? I am looking into updating a Drupal 4 site. The Node Export module does not seem to have a release suitable for Drupal 4. Can anyone recommend an alternative module or procedure?  The site is running Drupal 4.6.3. As you can see, the off-topic page isn&#39;t quite right...    Could this (minor) issue be fixed? How do I make the method return type generic? Consider this example (typical in OOP books):    I have an Animal class, where each Animal can have many friends. And subclasses like Dog, Duck, Mouse etc which add specific behavior like bark(), quack() etc.  Here's the Animal class:  public class Animal {     private Map&lt;String,Animal&gt; friends = new HashMap&lt;&gt;();      public void addFriend(String name, Animal animal){         friends.put(name,animal);     }      public Animal callFriend(String name){         return friends.get(name);     } }   And here's some code snippet with lots of typecasting:  Mouse jerry = new Mouse(); jerry.addFriend("spike", new Dog()); jerry.addFriend("quacker", new Duck());  ((Dog) jerry.callFriend("spike")).bark(); ((Duck) jerry.callFriend("quacker")).quack();   Is there any way I can use generics for the return type to get rid of the typecasting, so that I can say      jerry.callFriend("spike").bark(); jerry.callFriend("quacker").quack();   Here's some initial code with return type conveyed to the method as a parameter that's never used.   public&lt;T extends Animal&gt; T callFriend(String name, T unusedTypeObj){     return (T)friends.get(name);         }   Is there a way to figure out the return type at runtime without the extra parameter using instanceof? Or at least by passing a class of the type instead of a dummy instance. I understand generics are for compile time type-checking, but is there a workaround for this? Prison problem: locking or unlocking every $n$th door for $ n=1,2,3,...$ I have a problem called "The Prison Problem" that I need to explain to my 9-year-old cousin. I would think that he has just started learning about divisors and perfect squares, and as such, I have a proposed solution. Any input from you guys would be welcome, as to what is the best way to go about this.  Problem:  There was a jail with 100 cells in it, all in a long row. The warden was feeling very jolly one night and told his assistant that he wanted to give all the prisoners a wonderful surprise. While they were sleeping, he wanted the assistant to unlock all the cells. This should be done, he told the assistant, by putting the key in each lock, turning it once. The assistant did this, then came back to report that the job was done. Meanwhile, however, the warden has second thoughts. "Maybe I shouldn't let all the prisoners free," he said. "Go back and leave the first cell open, but lock the second one (by putting the key in and turning it once). Then leave the third open, but lock the fourth, and continue in this way for the entire row." The assistant wasn't very surprised at this request as the warden often changed his mind. After finishing this task, the assistant returned, and again the warden had other thoughts. "Here's what I really want you to do," he said. "Go back down the row. Leave the first two cells as they are, and put your key in the third cell and turn it once. Then leave the fourth and fifth cells and turn the key in the sixth. Continue down the row this way." The assistant again did as instructed. Fortunately, the prisoners were still asleep. As a matter of fact, the assistant was getting pretty sleepy, but there was no chance for rest yet. The warden changed his mind again, and the assistant had to go back again and turn the lock in the fourth cell and in every fourth cell down the row. This continued all through the night, next turning the lock in every fifth cell, and then in every sixth, and on and on, until on the last trip, the assistant just had to turn the key in the hundredth cell. When the prisoners finally woke up, which ones could walk out of their cells?  Proposed solution:  Ten cells are left open after this process. Every cell that is a perfect square will remain open (1, 4, 9, 16, 25, 36, 49, 64, 81, and 100). If a number is not a perfect square, then it has an even number of divisors, therefore it will be "toggled" an even number of times and end up where it started (closed). Perfect squares have an odd number of divisors, so they will end up the opposite of where they started (open). How to avoid noisy renders in Cycles? I know that this question is a bit old or maybe overdone, but I'm running the latest edition of Blender and when I use the Cycles engine I get really fuzzy results and I can't find a simple, non-compromising solution to the quality.  I don't know exactly what I'm doing wrong here, but I'm sure others share my frustration.  Leaving everything in default settings, I started a new project and switched to the Cycles render.  I duplicated the cube and set colors for two Diffuse BSDF shaders, then went ahead and made walls and a floor all sharing the same diffuse shader.  I made two windows to emit blue light.  The screenshot has gaps between the walls because of the setup:  I'm aware that it's considered very incomplete and many have come to terms with some amount of noise, but is this normal?  Furthermore, with default settings or not, I can't change the amount of noise produced.  Supposedly, using "progressively refine" in the rendering tab should make it refine itself indefinitely, however Cycles only counts to 10 refines and then stops, creating a render which is a pixel-perfect match of the ordinary rendering method when it's completed.  I understand that there are tricks that can be used to reduce noise, but at the cost of extra processing time and usually small quality conflicts, like blurring.  My question essentially boils down to is this Cycles' current limit? Can I set up WhatsApp on my desktop when my smartphone is broken? arbitrary large finite sums of an uncountable set. How to prove that given an uncountable subset $A$ of $R^+$, there exits a finite number of elements in A whose sum is arbitrarily large? Why isn't $\lim \limits_{x\to\infty}\left(1+\frac{1}{x}\right)^{x}$ equal to $1$? Should the noun after "any" be singular or plural? I always thought with "any" I should use the plural, but on the internet I can find both:   It can be found in any book. It can be found in any books Do you have any books? It can be said in any language.  This can be understood by anyone.  It has been used in any form.   So, what's correct?  Is there any rule? Prove Quotient Group Isomorphism Let $G = (\mathbb{C} - \{0\}, \cdot)$, a subgroup $U = \{x+yi \mid x^2 + y^2 = 1\}$. Use the Fundamental Theorem to show that $G/(\mathbb{R}_{&gt; 0},\cdot)$ is isomorphic to $U$ where $\mathbb{R}_{&gt; 0}$ denotes the positive reals.  I am struggling to find the correct mapping from $G$ to $U$ that results in the the kernel being the nonnegative reals under multiplication. I'm hoping to get help with this mapping then I can show it is a homomorphism and onto and can use the Fundamental Theorem. How exactly do automatic updates work? I received an email this morning stating that my Wordpress site had been automatically updated to the latest version. I knew about the feature but I've always wondered exactly how it works.  PHP isn't a permanently-running process: it only runs when requested. So as far as I can tell, Wordpress can only update itself when someone loads a web page. But the update process is not instantaneous, so surely a user visiting the site would have a really slow page load.  Is there a different trick they use for automatic updates? I've searched all over the place but haven't found any explanation. It seems that I'm missing something about this.  First of all, the series is convergent: $\lim_{n\rightarrow\infty}\frac{2^{-n-1} (n+1)^2}{2^{-n} n^2}=\frac{1}{2}$ (ratio test)  What I tried to do is to find a limit of a partial sum $\lim_{n\rightarrow\infty}S_n$ as follows: $S_n=\frac{\frac{1}{6} n (n+1) (2 n+1)}{\frac{1-\left(\frac{1}{2}\right)^n}{2 \left(1-\frac{1}{2}\right)}}$. Still, the limit is $\infty$ and I'm clearly doing something wrong.