I am trying to code a program that allows to enter various words(step by step) until one types in "quit" . I am having trouble stopping the loop (even with the word quit typed, it doesn't stop) Using System.out.println(sum); I can check that the words are adding up, but it never stops..  ((Summary : if(string == "quit") does not work and for (String end = "quit"; string!=end;) does not work )) Sorry if its hard to read. its my second day coding :(  public static void main(String[] args) {     java.util.Scanner scanner = new java.util.Scanner(System.in);     String sum = "";     System.out.println("Type in a word");     String string = scanner.nextLine();     if (string == "quit")     {System.out.println("Ending system");      }     else{     for(String end = "quit"; string!=end;  )     {         sum = sum + " " + string;         System.out.println(sum);         System.out.println("Type in another word");         String stringextra = scanner.nextLine();         if(stringextra == "quit"){break;}         string = stringextra;      }      scanner.close();     System.out.println("Stopping... due to the word quit");     System.out.println("all the words typed are " + sum);      }  }}
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?
Why do physicists believe that there exist magnetic monopoles? Sum of $\frac{1}{(2n)(2n+1)}$ from $1$ to infinity Do companies have IT "spyware" on corporate iPhones? Footnotes in tables? I have setup a project of 250 frames with a flag and a wind force field. It works fine until I change the length of the project to 520 frames, then the flag is frozen after frame 250. There must be a simple way to change this. Thanks for any help. Regards, Daniel. If shuffle-playing playlist &times;100 resulted in [10 13 10  3  2  2] different songs being repeated [1 2 3 4 5 6] times, what is the estimate for the total number of songs? (assuming shuffle play was completely random)  Update: (R code)  k &lt;- 50 # k number of songs on the disk indexed 1:k n &lt;- 100 # n number of random song selections m &lt;- 20 # m number of repeat experiments colnum &lt;- 10 mat &lt;- matrix(data=NA,nrow=m,ncol=colnum) df &lt;- as.data.frame(mat) for(i in 1:m){   played &lt;- 1+floor(k*runif(n)) # actual song indices (1:k) selected    freq &lt;- sapply(1:k,function(x){sum(played==x)})   # = number of times song with index x is being played   histo &lt;- sapply(1:colnum,function(x){sum(freq==x)});   for(j in 1:colnum){    df[i,j] &lt;- histo[j]   } } df   Resulting in: e.g. 20 distributions (V1=number of single plays, V2=number of double plays, etc):     V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1  15 13 11  1  2  2  0  0  0   0 2  15 12 10  1  4  0  1  0  0   0 3  12 14  7  6  3  0  0  0  0   0 4  17 16  6  4  2  0  1  0  0   0 5  17 10 12  5  0  0  1  0  0   0 6  13 15 11  6  0  0  0  0  0   0 7  10 14  9  3  2  1  1  0  0   0 8  12 17  5  6  3  0  0  0  0   0 9   9 19  8  3  1  2  0  0  0   0 10 13  9 11  6  1  0  1  0  0   0 11 16  9 12  5  2  0  0  0  0   0 12 15  9 11  6  2  0  0  0  0   0 13 19  9  7  4  4  1  0  0  0   0 14 17 11  4  7  3  1  0  0  0   0 15 11 20  8  1  3  1  0  0  0   0 16 14 12 10  5  0  2  0  0  0   0 17  9 12  8  7  3  0  0  0  0   0 18 10 15  9  4  2  0  1  0  0   0 19 14 11 12  7  0  0  0  0  0   0 20 16 14 11  3  1  1  0  0  0   0   Now I need to get from here to the Poisson modelling--my R is a bit rusty (?lmer)...--Any help would be appreciated...  Attempted Poisson modelling: disappointing fit?!  plot(1:colnum,df[1,1:colnum],ylim=c(0,30),    type="l",xlab="repeats",ylab="count") for(i in 1:m){   clr &lt;- rainbow(m)[i]   lines(1:colnum,df[i,1:colnum],type="l",col=clr)   points(1:colnum,df[i,1:colnum],col=clr) }  df.lambda=data.frame(lambda=seq(1,5,0.1),ssq=c(NA));df.lambda for(ii in 1:dim(df.lambda)[1]){   l &lt;- df.lambda$lambda[ii]       ssq &lt;- 0       for(i in 1:20){         for(j in 1:10){           ssq &lt;- ssq + (df[i,j] - n*dpois(j,l))^2         }       }       print(ssq)       df.lambda$lambda[ii] &lt;- l   df.lambda$ssq[ii] &lt;- ssq     }     df.lambda     lambda.est &lt;- df.lambda$lambda[which.min(df.lambda$ssq)] lambda.est # 2.4 points(x &lt;- 1:10, n*dpois(1:10,lambda.est),type="l",lwd=2)  100*dpois(1:10,3) n/lambda.est   the estimated lambda stays around 2.3, with an n estimate of around 43; the fitted curve seems very discrepant, and seems to worsen with rising n !?  Doesn't this have to do with the fact, that our repeats are different from the 'classical' Poisson distributions: it's not just ONE event that repeats itself x number of times, but the sum of repeats of different items (songs)?! Is there a way for me to bind a key that will allow multiple units in my control group to all use the same spell at once?  For example, if I have 3 centaurs as chen, and I have them all selected. Can I press one key to make them all warstomp at the same time?   Or if I have 3 familiars as Visage. When I have all three selected, is there a button I can press to have them all stun at the same time? "Fatal error: Class name must be a valid object or a string in C:\xampp\htdocs\uc\includes\common.inc on line 7506"  The error above showed up unexpectedly. I was adding a "Long text" field to a content-type, but when I expected to be brought to a saved field configuration page, I instead got a Fatal error on every page.  I had a look at includes\common.inc:  /**  * Get the entity controller class for an entity type.  */ function entity_get_controller($entity_type) {   $controllers = &amp;drupal_static(__FUNCTION__, array());   if (!isset($controllers[$entity_type])) {     $type_info = entity_get_info($entity_type);     $class = $type_info['controller class'];     $controllers[$entity_type] = new $class($entity_type); // Line 7506   }   return $controllers[$entity_type]; }   However, I just don't understand Drupal at a low enough level to understand the relationships between these variables and functions.  I also searched Drupal for people with a similar problem:  (1)  who claims that I have to install the submodule "Relation Endpoints Field", but searching Drupal, .  (2) :  DELETE FROM cache; DELETE FROM cache_filter; DELETE FROM cache_menu; DELETE FROM cache_page; DELETE FROM watchdog;   (via , misleading name, I know.)  Clearing those tables from the cache did not help.  (3) And another user . Because I can't find a module specifically pertaining to old search facets, I went into MySQL system table, and marked the Search module's line with a 0 status, indicating to stop loading the module altogether.  On that same link as (3), one user suggested enabling the , so I dropped all the tables, imported the latest stable .sql, and installed the module, but after recreating the problem (trying to add a field to a content-type), that as well concluded fruitless.  Still, the problem remains  The Fatal error shows up on every page, making the site completely non-functional. Any help or direction would be immensely appreciated. Thank you for looking. What are the pros and cons of flip lock vs. twist lock on tripods? I am in search of a tripod. While doing a bit of research myself, I came to know that there are two broad variants of leg locks, viz. flip and twist lock. In many forums, I find people expressing conflicting views preferring each one over the other. This seems to confuse me even more while not being aware of what each type of lock operates. What are the prime considerations in choosing a particular lock system? Disable automatic driver update for only one device in Windows 10 Is there a way we can disable automatic driver update for a specific device in Windows 10? The updated driver for that device (Intel Management Engine Interface 11.x in particular) causes problems on some laptops during. The version 9.x works perfect.  I don't want to disable automatic driver installation for all devices. Bad match with a gaming group, how to leave? I have sometimes joined groups whose play style didn't work for me. At some point it became clear that as much as I wanted to enjoy the game I couldn't. And I was probably undermining the fun at the table for others too.  What is the best way to leave the group? Quietly or with a few explanations? Announce it in person or by email/phone/forum? Is it OK to recruit players from the group for another game? Can someone please explain this weird Pygame importing convention? How to obtain $f(x)$, if it is known that $f(f(x))=x^2+x$? Is there an easy way to calculate the total cost of tolls for a trip within the United States? Capitalize and punctuate "let us continue this discussion in chat" Stack Exchange has a feature to help move extended discussions out of comments and into chat, but when you use it, it automatically writes the following message for you:  let us   Could we get the orthography fixed?  I'd like it to read:  Let us .  That's a capital letter at the beginning and a period at the end. In Python, how do I get a function name as a string, without calling the function?  def my_function():     pass  print get_function_name_as_string(my_function) # my_function is not in quotes   should output "my_function".  Is such function available in Python? If not, any ideas on how to implement get_function_name_as_string, in Python? Should one ask generic or specific question? Let's assume that one has some problems with coding or designing specific project. Should one ask general question about techniques, algorithms, generic problem (anonymising the project references), or should one ask about specific problem in specific problem? Or perhaps something in between?  Example:   generic: Cross-browser implementation of “HTTP Streaming” (push) AJAX pattern specific: How to implement AJAX-y 'incremental blame' view in gitweb (git web interface in Perl)?   If one should ask generic questions, how to anonymise problem? If one should ask specific question, how avoid 'homework' syndrome? reflecting direct light on glossy surface in Cycles Working in Cycles.  Say I have a "disco ball" with a glossy shader. I'm pointing a spot light to it, and I'm trying to have the reflections of that light illuminate the diffuse material on the walls with the patterns from the ball.    I get this:    but I'd like to get something like:    For the illustration I placed a point light inside the ball an removed faces. But what I'd like to do is move the light around the ball so that the light reflected from it changes like it would do in real life.   Is that possible at this point?  EDIT:  Just for the record here's the image rendered in LuxRender (yet another program to learn...) I have a list of structs and I want to change one element. For example :  MyList.Add(new MyStruct("john"); MyList.Add(new MyStruct("peter");   Now I want to change one element:  MyList[1].Name = "bob"   However, whenever I try and do this I get the following error:     Cannot modify the return value of   System.Collections.Generic.List.this[int]‘ because it is not   a variable   If I use a list of classes, the problem doesn't occur.  I guess the answer has to do with structs being a value type.  So, if I have a list of structs should I treat them as read-only? If I need to change elements in a list then I should use classes and not structs? I've just started using TikZ and need to create a simple triangle commutative diagram like this one.    The closest I've been able to get is this.   How do I get the h arrow to go from A2 to A3? Everything I've tried just causes errors.  Here's my current code:  \begin{tikzcd}[column sep=small] A \arrow{r}{i}  \arrow{rd}{g}    &amp; A3 \arrow{d}{h} \\     &amp; A2 \end{tikzcd}