I am making a Game of Life program, early stages of it. When I run the program and get to the "Do you want to make..." and i input "y", it will go to the else, print my test statement of test3, and end the program. What am I overlooking?  public static void main(String[] args) {      Scanner kb = new Scanner(System.in);      String userInput = "";     char[][] initialGrid = new char[25][75];     char[][] world = makeInitialGrid(kb, userInput, initialGrid);     printGrid(world);     userInput = "y";     while (userInput == "y"){         System.out.println("Do you want to make a new generation? (y) yes (n) no");         userInput = kb.nextLine();         System.out.println(userInput);         if (userInput == "y"){             System.out.println("test1");             int numOfNeighbors = findNeighbors(world, 6, 2);             System.out.println("test2");             System.out.println(numOfNeighbors);             //makeNewGeneration(world);         } else {             System.out.println("test3");             break;          }     }     kb.close();
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?
How do I prepare best for my first wedding photography event? I am going to shoot a wedding this weekend, and I want to do my best for my friend's big day.    What can I do to prepare for the day in order to minimize failures and mistakes? How do I avoid missing important shots? What backup plan should I have?   I have been shooting for 6 years or so, and I know wedding is one of the hardest thing to do. I have told my friend what I end up producing will be of no match with the work of dedicated wedding photographers, not even the ones that are about to fall out of business.  They are on a tight budget, they said some photos are still better than none, they really must minimize the cost as much as they can. I exaggerated again that my photos will be worse off than the cheapest wedding photographer you can find.  She has been a close friends for years, I want to do everything I can to help her.  Their wedding is at 12:30pm coming Sunday, I have visited the venue last Sunday at 12:30pm to check traffic condition and also the lighting.  The setup is mainly outdoor (no church), the indoor area will not have a good ceiling for bounce. Being at the middle of the day, this can mean some tricky fill flash. I have jot down a list of must-have shots. I am also asking for the seating plan and the event run-down.  Gear:   Canon EOS 60D , EF-S 15-85mm f/3.5-5.6 IS USM Canon EOS 450D (or I can borrow a 550D), EF 50mm f/1.4 Speedlite 580 EXII Speedlite 270 EXII Yongnuo 460 (a cheap but powerful manual flash as backup) Samsung EX-1 f/1.8 point and shoot (backup of a backup...?)   Other lenses that I have but I don't think will be useful:   50mm f/1.8 EF-S 50-250mm f/4.0-5.6 IS II EF-S 18-135mm f/3.5-5.6 IS (I have the better 15-85 on 60D, should I put this on the 450D as a backup allrounder?) EF-S 60mm f/2.8 Macro (should I replace 50mm f/1.4 with this for added macro? You can hardly use f/1.4 under direct sunlight if you want to have fill-flash)   I have two batteries for all cameras (60D 450D and EX1). I have like in total 64GB SD card (I am really inclined to get more, or bring a laptop for on-the-fly backup, or do both). I recently repaired my 580EXII, it has a brand new flash head so the recycle time is as good as it can be, I just need a tonne of batteries. No I don't have external power pack or battery grip for my cameras.  I have a great monopod, but a cheap tripod.  I am happy to bring everything, just putting them in the boot of my car. The carpark is on-site, walking from venue to my car is under 1 minute.  I will have my girlfriend carry the 450D and shoot details / non-portraits.  One concern that I have is fill flash, I really do not have a large surface to bounce off  from. I have shot events before but they are not as dynamic/critical as a wedding.  How do I prepare for differing weather conditions?  If its sunny, fill flash is probably going to be in every single shot. If its cloudy, I probably will turn off the flash. If it rains, my 60D should be fine I have used it in slight rain before, but I really don't know their plan and if they have extendable shelters etc.  What else should I prepare for? Having no experience I want to be as prepared as I can be. Maybe I have overlooked something, maybe there is something else I can do to ensure the shooting will go smoothly. Your help is greatly appreciated! Buying from Play store using a credit card with foreign billing address Is it possible to use a credit card with a foreign billing address to buy items from a local Play store? I have a Visa credit card from a German bank with a billing address in Germany registered in my Google Wallet. I have successfully used my Wallet to pay for online purchases from several online service providers in different foreign currencies so I am sure the credit card is correctly registered in my Wallet account. However, while physically located in the UK, I cannot complete any purchase from the UK Play store. At the point when I need to select my preferred payment method from my Wallet account, it shows my registered credit card greyed out with the text "Unsupported Payment method" next to it. Number of integer solutions of $x^2 + y^2 = k$ I'm looking for some help disproving an answer provided on a  I posted about computing the number of double square combinations for a given integer.    The original question is from the Facebook Hacker Cup       Source: Facebook Hacker Cup   Qualification Round 2011      A double-square number is an integer $X$   which can be expressed as the sum of   two perfect squares. For example, 10   is a double-square because $10 = 3^2 + 1^2$.   Given $X$, how can we determine the   number of ways in which it can be   written as the sum of two squares? For   example, $10$ can only be written as $3^2 + 1^2$   (we don't count $1^2 + 3^2$ as being different). On the other hand,   $25$ can be written as $5^2 + 0^2$ or as   $4^2 + 3^2$.      You need to solve this problem for $0 \leq X \leq 2,147,483,647$.      Examples:      $10 \Rightarrow 1$      $25 \Rightarrow 2$      $3 \Rightarrow 0$      $0 \Rightarrow 1$      $1 \Rightarrow 1$   In response to my original question about optimizing this for F#, I got the following response which I'm unable to confirm solves the given problem correctly.       Source:       Again, the number of integer solutions   of $x^2 + y^2 = k$ is four times the   number of prime divisors of $k$ which   are equal to $1 \bmod 4$.      Knowing this, writing a program which   gives the number of solutions is easy:   compute prime numbers up to $46341$ once   and for all.      Given $k$, compute the prime divisors of   $k$ by using the above list (test up to   $\sqrt{k}$). Count the ones which are   equal to $1 \bmod 4$, and sum. Multiply   answer by $4$.   When I go through this algorithm for $25$, I get $8$ which is not correct.          For each prime factor (pf) of $25$ ($5$, $5$ are prime factors of $25$)         if pf % $4$ = $1$ (true for both $5$'s), add $1$ to count      return $4$ * count (count would be $2$ here).          So for $25$, this would be $8$ Let $A$ be an $m \times n$ matrix of rank $r$, let $I$ be a set of row indices such that the corresponding rows of $A$ are independent and let $J$ be a set of $r$ column indices such that the corresponding columns of $A$ are independent.  Let $M$ denote the $r \times r$ submatrix obtained by taking rows from $I$ and columns from $J$.  Then $M$ is invertible.  So far I've got: Let $B$ be the $m \times r$ matrix obtain from taking the rows from $J$.  $B$ is row-reducible to having a pivot in each column or else $Ax = 0$ has more than one solution, a contradiction.  Also, the dimension of the row space of $B$ equals $r$ as well. I am totally new to Linux, servers and websites. I recently set up Apache2, Python, PHP, and MySQL for setting up a LAMP server. I am using Xubuntu 16.04 and PHP 7.0.11. I followed a guide and placed a PHP file named testing.php in it with:  &lt;?php phpinfo(); ?&gt;    It doesn't show anything on localhost/testing.php All it shows is the code itself. Calculating conditional entropy given two random variables I have been reading a bit about conditional entropy, joint entropy, etc but I found this: $H(X|Y,Z)$ which seems to imply the entropy associated to $X$ given $Y$ and $Z$ (although I'm not sure how to describe it). Is it the amount of uncertainty of $X$  given that I know $Y$ and $Z$? Anyway, I'd like to know how to calculate it. I thought this expression means the following:  $$H(X|Y,Z) = -\sum p(x,y,z)log_{2}p(x|y,z)$$  and assuming that $p(x|y,z)$ means $\displaystyle \frac{p(x,y,z)}{p(y)p(z)}$, then  \begin{align} p(x|y,z)&amp;=\displaystyle \frac{p(x,y,z)}{p(x,y)p(z)}\frac{p(x,y)}{p(y)}\\&amp;=\displaystyle \frac{p(x,y,z)}{p(x,y)p(z)}p(x|y) \\&amp;=\displaystyle \frac{p(x,y,z)}{p(x,y)p(x,z)}\frac{p(x,z)}{p(z)}p(x|y)\\&amp;=\displaystyle \frac{p(x,y,z)}{p(x,y)p(x,z)}p(x|z)p(x|y) \end{align} but that doesn't really help.  Basically I wanted to get a nice identity such as $H(X|Y)=H(X,Y)-H(Y)$ for the case of two random variables.  Any help?  Thanks How to execute consecutive commands from history? Suppose I want to execute a sequence of four commands that I have executed before. If the first one is 432 in the command-history, then I could do:  $ !432; !433; !434; !435   I'm curious, is there a more efficient way to accomplish this? 'const int' vs. 'int const' as function parameters in C++ and C Consider:  int testfunc1 (const int a) {   return a; }  int testfunc2 (int const a) {   return a; }   Are these two functions the same in every aspect or is there a difference?  I'm interested in an answer for the C language, but if there is something interesting in the C++ language, I'd like to know as well. Variable with colon dash ${VAR:-} Icon missing when application is launched I've created an application launcher in /usr/share/applications that launches rdesktop. The file specifies an icon name and I've added the icons to:   /usr/share/icons/HighContrast/48x48/apps /usr/share/icons/HighContrast/22x22/apps /usr/share/icons/HighContrast/256x256/apps /usr/share/icons/HighContrast/32x32/apps /usr/share/icons/HighContrast/scalable/apps-extra /usr/share/icons/HighContrast/24x24/apps /usr/share/icons/HighContrast/16x16/apps /usr/share/icons/hicolor/scalable/apps /usr/share/icons/hicolor/128x128/apps /usr/share/icons/hicolor/16x16/apps   I then drug the launcher to the taskbar and the launcher with the correct logo is visible in the taskbar. However, when I start the task, a new icon is created in the taskbar, a square with a question mark in the center.  What icons do I need and where, so that the taskbar displays the correct icon for the application when it is launched?  The .desktop file contents:   [Desktop Entry] Version=1.0 Terminal=false Icon=mswindows Type=Application Categories=Network; Exec=rdesktop win7shared1 -g 1680x1000  Name=win7shared1 GenericName=rdesktop Comment=Open windows desktop  Keywords=Windows StartupNotify=false How do I boot Windows 8 into Safe Mode? I have Windows 8 Enterprise x64. It's installed a virtual machine. After trying to update VMWare's guest extension it black screened. After resetting it, now the virtual machine won't boot. It just says "automatic repair couldn't repair your PC"   Everything I do ends with an error or it coming back to this screen. If I go to Troubleshoot > Advanced Options > Start up settings and then go to Safe Mode, all it will do is say "preparing automatic repair" and then "diagnosing your PC" and then will come straight back to the "automatic repair couldn't repair your PC" screen. It's as if it doesn't even attempt to go into safe made.   Is there anything else I can do before I reformat? Error - SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM I've been using this piece of code I've written and it's working in this most unclear manner. I wish to insert a row into the database which includes two columns of DateTime:  myrow.ApprovalDate = DateTime.Now myrow.ProposedDate = DateTime.Now   And yet, when I update the database I receive this error:     SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.    I've even tried copying an inserted value from the database and hard code it into the object being updated:  // I copied this value from the DB myrow.ApprovalDate =  Convert.ToDateTime("2008-12-24 00:00:00.000");   Still same error, the strange part is that the above trick worked for the first insert to the DB but failed from there on. Any ideas what's going on? If I take the $k \in \mathbb{N}$ power of 10 and mod it by a large prime, I notice that the remainders repeat at some point.  For instance $10^k mod~7$ seems to repeat every $8$th value of $k$.  Given $k$ (the power of ten), and a large prime number $p$, how can I compute the size of the cycle?  I tried writing a python script that computes the first instance of a repeat. However, I don't know if this works since a single instance of a repeat may not necessarily mean a full cycle. What exactly are genes, DNA and chromosomes. How do they relate to each other and what is their function? So I am new to biology and I have been reading, and searching the web, but I couldn't understand the whole framework of a cell. So as I understood:    A DNA, is a double chain of Nucleotides (A,T,G,C and a sugar) and a phosphate residue. Some parts of a DNA code a gene and some do not, exons and introns accordingly. As I understand it these the sequences of exons hold genes and the whole sequence is called genome. Now I read in the book Introduction to Computational Molecular Biology by J. C. Setubal and J. Meidanis. that I cite Each cell of an organism has a few very long DNA molecules. Each such molecule is called a chromosome. So each X shaped thing called a chromosome holds one DNA molecule?   Or is each "hand" of the chromosome one complete double helix of DNA so we have 23 pairs of such chromosomes? or is it that each we 23 pairs Xs?   Shouldn't we have just one uniquely identifiable DNA sequence? I am asking this, because I have also read that each chromosome encodes a different part of one's genome. Does this mean we have several DNA sequences?   This is really bothering me, since I can't figure out the correct structure of a cell.   EDIT: Now if each chromosome contains a pair of DNA helices. We have 46 chromosomes so overall within the cell there are 92 DNA sequences? All of which are the same? Or are they different? If they are different how do they code for different aspects of one's genome? How to avoid "completely" dark shadow using directional light (as Sun) ? Look at my scene:     Sun is rising and as you can see the scene is realistic; I mean, that what is in shadow is almost completely dark. This is correct, but i would like something less "dark", like an HDR.  These are some parameters i'm using:     This is my unique Light in scene (Sun):     I'm using also a Post-Processing profile with "Eye Adaption" unflagged.  Can you suggest me what i've to change to make my object affected by shadow less.. dark ?   Thanks Change the default editor when sudo visudo When doing sudo visudo, the default editor is nano. I want to change it to vi or vim.     I already made vim the default editor, and use it as a substitute for gedit to open php, .txt, .c and .h files, by placing a vim.desktop file in ~/.local/share/applications/ and by correctly editing either  ~/.local/share/applications/mimeapps.list or /etc/gnome/defaults.list. However apparently this does not apply to nano.    Any clue ? How would one throw an unwilling creature? My bugbear barbarian, who can lift about double the weight of a wolf, wanted to throw the wolf at a second wolf. How would we go about doing that given existing rules options? Numbered list in rows in tables I want to have numbered listing in each row, I've tried with \rownumber, but it doesn't work. I wrote a number at the beginning, but Could it be automatically?  Can you help me? This is my code:  \documentclass[10pt, a4paper]{article}  \usepackage{fontspec} \setmainfont{Arial}  \usepackage{color, colortbl} \definecolor{Gray}{gray}{0.9}  \begin{document}  \begin{table}[h!] \tiny \begin{tabular}{|&gt;{\raggedright\arraybackslash}m{30mm}|&gt; {\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|&gt;{\raggedright\arraybackslash}m{5mm}|} \hline \multicolumn{1}{|&gt;{\centering\arraybackslash}m{30mm}|}{\rowcolor{Gray}\textbf{Text}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 1}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 2}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 3}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 4}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 5}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 6}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 7}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 8}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 9}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 10}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 11}} &amp; \multicolumn{1}{|&gt;{\centering\arraybackslash}m{5mm}|}{\textbf{Sem 12}}\\ \hline 1. Text text text text text text text text text text text text text &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;\\\hline 2. Text text text text text text text text text text text text text &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;\\\hline 3. Text text text text text text text text text text text text text  &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;\\\hline 4. Text text text text text text text text text text text text text &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;\\\hline  \hline \end{tabular} \end{table}  \end{document} I'm trying to install the Jupiter power settings app but, I read it is no longer compatible with the new kernel. Is there a similar program or a way to manage the power settings on 13.04? How to find image coordinates of the rendered vertex? I have a simple mesh of a cube.  I would like to know what are the coordinates of each vertex in the rendered image (i.e. for each 3d vertex I'd like to know it's pixel coordinates).  Is there a way to do this?  Clarification:  I'm experimenting with a pose estimation algorithm (i.e. finding out the 3d pose of the object) from a (set of) 2d image(s).  Instead of taking an image of a real object with a real camera I synthetically render the image of a cube using blender.  In this way I know the pose of the object and the intrinsics of the camera, so I can easily validate the results of the pose estimation algorithm. Pose estimation algorithms usually require to provide them with world points on the object and the corresponding image points.  So what I'm looking for is a way to produce a dump of correspondences of the 3d point &lt;--> image point as a byproduct of the rendering procedure. Thanks, Alex