Please don't get confused by my full complex code. Let me walk you through my code and problem.  I have built a class (CharDrawing), in which I am calling one method (charDrawing) inside another method (stringDrawing), let's say two times, in full code below. And it is returning me desired object.  Now, I am trying to replace these 2 calls of charDrawing() method, using for loop. See the commented part below.  sr=charDrawing(sr,x,y,w,h,pw,"G"); sr=charDrawing(sr,x+w+5,y,w,h,pw,"B");      /*for (int i=0;i&lt;l;i++)     {                              sr=charDrawing(sr,x+i*(w+gap),y,w,h,pw,Character.toString(s.charAt(i)));     }*/   But my for loop is not behaving same as above two lines? What is the difference?  After applying for loop I am not getting same result.  Debugging: These are my debugging result of objects in both cases. Refer full code below.  Code run without for loop:  simple object line 1com.badlogic.gdx.graphics.glutils.ShapeRenderer@1ef3e2e simple object line 2com.badlogic.gdx.graphics.glutils.ShapeRenderer@1ef3e2e   Code run using for loop:  for loop objectcom.badlogic.gdx.graphics.glutils.ShapeRenderer@13841b8 for loop objectcom.badlogic.gdx.graphics.glutils.ShapeRenderer@13841b8   My Analysis: As you can see, in both cases, same objects are getting updated in each line. Then why am I not getting same results?  Full Code:  public class CharDrawing {      public ShapeRenderer stringDrawing(ShapeRenderer sr,float x, float y, float w, float h,float pw,float gap,String s) {          int l=s.length();         sr.begin(ShapeType.Filled);         /*for (int i=0;i&lt;l;i++)         {                                  sr=charDrawing(sr,x+i*(w+gap),y,w,h,pw,Character.toString(s.charAt(i)));           System.out.println("for loop object"+sr);         }*/         sr=charDrawing(sr,x,y,w,h,pw,"G");         System.out.println("simple object line 1"+sr);         sr=charDrawing(sr,x+w+5,y,w,h,pw,"B");         System.out.println("simple object line 2"+sr);         sr.end();         return sr;     }     public ShapeRenderer charDrawing(ShapeRenderer sr,float x, float y, float w, float h,float pw,String c)     {          if(c=="G")         {             //sr.begin(ShapeType.Filled);             sr.setColor(200/255f, 245/255f,112/255f, 1);  //color1             sr.rect(x,y,w,h);             sr.setColor(107/255f, 107/255f,107/255f, 1);   //color2             sr.rect(x+pw,y+pw,w*0.35f,h-2*pw);             //sr.setColor(407/255f, 107/255f,107/255f, 1); //for debugging             sr.rect(x+pw+w*0.35f,y+pw+h*0.5f-pw,0.65f*w-pw,h*0.5f-pw);             sr.rect(x+2*pw+w*0.35f,y,0.65f*w-3*pw,h*0.5f-pw);                    //sr.end();         }          if(c=="B")         {             //sr.begin(ShapeType.Filled);             sr.setColor(200/255f, 245/255f,112/255f, 1);  //color1             sr.rect(x,y,w,h);             sr.setColor(107/255f, 107/255f,107/255f, 1);   //color2             //sr.setColor(407/255f, 107/255f,107/255f, 1); //for debugging             sr.rect(x+pw,y+pw,w-2*pw,0.5f*h-1.5f*pw);             sr.rect(x+pw,y+0.5f*h+0.5f*pw,w-2*pw,0.5f*h-1.5f*pw);             //sr.end();         }          return sr;     } }   FYI.. I am using this libGDX ShapeRenderer api to draw few shapes.   Apologies if it's very basic concept and I am unable to figure it out  Thanks.
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?
"... that had stopped half an hour ago" VS " ... that had stopped half an hour before/earlier" This is a sentence I read:       The engines that had stopped half an hour ago were in action again.   In my opinion, ago in the above sentence is used incorrectly. It should be replaced by before or earlier:     The engines that had stopped half an hour before were in action again.   The engines that had stopped half an hour earlier were in action again.   I think ago can only used in the past tense rather than past perfect tense.  Here is a correct sentence, making the correct use of ago as follows:     The engines that stopped half an hour ago are in action again.   Is this thinking correct? I have a dataset for which I have multiple sets of binary labels. For each set of labels, I train a classifier, evaluating it by cross-validation. I want to reduce dimensionality using principal component analysis (PCA). My question is:  Is it possible to do the PCA once for the whole dataset and then use the new dataset of lower dimensionality for cross-validation as described above? Or do I need to do a separate PCA for every training set (which would mean doing a separate PCA for every classifier and for every cross-validation fold)?  On one hand, the PCA does not make any use of the labels. On the other hand, it does use the test data to do the transformation, so I am afraid it could bias the results.  I should mention that in addition to saving me some work, doing the PCA once on the whole dataset would allow me to visualize the dataset for all label sets at once. If I have a different PCA for each label set, I would need to visualize each label set separately. How can I stop being prompted to unlock the 'default' keyring on boot? Finding $\lim_{n\to\infty}\binom{2n}{n}$ I found a limit problem which is $\lim_{n\to\infty}{2n \choose n}$ as we know that $\sum_{i=0}^{n}{n \choose i}^2={2n \choose n}$ now we could transform the given problem as $\lim_{n\to\infty} \sum_{i=0}^{n}{n \choose i}^2$ and as $\sum_{i=0}^{n}{n \choose i}^2$ is a polynomial in $n$, therefore, $\lim_{n\to\infty}\sum_{i=0}^{n}{n \choose i}^2=\infty$ Please tell me if my solution is correct or not,and if it is incorrect then please provide me a solution.  Thanks Find the integer which is closest to the value of   $\frac{1}{\sqrt[6]{5^6+1}- \sqrt[6]{5^6-1}}$  I have tried putting them between n and n+1 and tried manipulating  n but I cant seem to find a strategy. I got a integrated GD, which is Intel, and another discrete GD, AMD Radeon 6490 HD I am using ubuntu 11.10  1st, when I boot into Windows, my GD is indeed AMD Radeon 6490 HD, but when I boot into Ubuntu, it shows that I have AMD Radeon 6470 instead.  2nd, I try most methods only to install driver for my AMD/ATI graphic card. First by jockey(fail, boot with unity 2D instead) and install manually (fail, boot into blank screen).   3rd, I give up using the AMD/ATI graphic card. Then I got a new problem. Both my graphic cards are powered on on startup, which causes my laptop to over heat.   I view the content of /sys/kernel/debug/vgaswitcheroo/switch  0:DIS: :Pwr:0000:01:00.0 1:IGD:+:Pwr:0000:00:02.0   Then I switch off IGD using echo OFF &gt; /sys/kernel/debug/vgaswitcheroo/switch and I get  0:DIS: :Off:0000:01:00.0 1:IGD:+:Pwr:0000:00:02.0   But after I reboot, the discrete graphic card is powered on again. How to solve this? How can I simulate a slow machine in a VM? What Happens When A Gravitational Wave Interacts With Another One? If two gravitational waves came in contact with each other what would happen? In another question entirely, what happens when a higher gravitational field interacts with a weaker one. How to create a good glass reflection with Principled BSDF Solution to German Tank Problem Is there a formal mathematical proof that the solution to the  is a function of only the parameters k (number of observed samples) and m (maximum value among observed samples)? In other words, can one prove that the solution is independent of the other sample values besides the maximum value? Is there any built-in way to get the length of an iterable in python? For example, files, in Python, are iterable - they iterate over the lines in the file. I want to count the number of lines.   One quick way is to do this:  lines = len(list(open(fname)))   However, this loads the whole file into memory (at once). This rather defeats the purpose of an iterator (which only needs to keep the current line in memory).  This doesn't work:  lines = len(line for line in open(fname))   as generators don't have a length.  Is there any way to do this short of defining a count function?  def count(i):     c = 0     for el in i: c += 1     return c   To clarify, I understand that the whole file will have to be read! I just don't want it in memory all at once How does "Reputation" work? On Stack Exchange, users may gain a certain level of reputation.  What does reputation do? How can a user gain or lose reputation?   See also   in the Help Center  - Maximum amount of votes a user can use in a day and reputation requirements to vote.  - How to get an exact overview of the actions that got you your reputation.  - A full list of all privileges granted at each reputation level on all sites. Why are votes anonymous? Let's make with the transparency and have them publicly attributed I was presented with the following problem:      Prove that there exist solutions to $x^2+y^2=z^n$ for all $n$, with $x,y,z, n \in \mathbb{N}$   I showed that by taking any Pythagorean triple $x^2+y^2=z^2$ and multiplying by $z^{2(n-1)}$ we get $(z^{n-1}x)^2+(z^{n-1}y)^2=(z^2)^n$, which allows me to generate solutions easily for any value of $n$. I managed to find several similar questions on this site, such as  concerning the specific case $n=3$. I notice that all of these questions take a similar approach and start with a Pythagorean triple and use it to generate general solutions.  Is there a way to prove the statement (or better yet provide solutions to the equation) without first relying on Pythagoras? I read this book once when I was in middle school. A girl solves a murder or a mystery on a spaceship. It was a thin paperback books.   All I can remember is that there was an alien, and there was a movie star or actress or famous makeup artist on the ship traveling with another woman. By the end of the book the murderer was the woman the actress was traveling with who forced her to use her makeup skills to disguise her, and she was really some kind of alien. How do I debug Node.js applications? Let $X\subset \mathbb{R}$ Lebesgue measurable, $|X|<|\mathbb{R}|$, is it true that $X$ is null? Let $X\subset \mathbb{R}$ Lebesgue measurable, $|X|&lt;2^{\aleph_0}$, is it true that $X$ is null?  Of course I am not assuming the Continuum Hypothesis.   EDIT: It might be helpful to know that all Borel measurable sets have cardinality either $\aleph_0$ or $2^{\aleph_0}$. Then a measurable set of cardinality strictly between those two must be Lebesgue but not Borel measurable. As far as I understand, whatever can be done using DeclareMathOperator can also be achieved using newcommand, but not the other way around. If this is the case, what are the circumstances where DeclareMathOperator is the better choice? When should I take solely newcommand?  I found a question regarding , and I wonder what other aspects should be taken into consideration when it comes to choosing which method to use when defining math operators. Aligning multiple figures/tikzpicture vertically and horizontally I'm trying to align four figures vertically and horizontally. But I couldn't get it right in spite of repeated tweaks.  Can someone help me out?   Here is a MWE -- there are no errors, but the figures don't come out scaled properly.  \documentclass[12pt]{llncs}  \usepackage{fullpage} \usepackage{graphicx}  \pdfoutput=1 \usepackage{epsf} \usepackage{epsfig} \usepackage{epstopdf} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsmath} \usepackage{latexsym} \usepackage[all]{xy} %\pagestyle{empty} \pagestyle{plain} %\usepackage{algorithmic} %\usepackage{algorithm} \usepackage{hyperref} \usepackage{nameref} %\usepackage{MnSymbol} \usepackage{tikz} \usepackage{caption} \usepackage{subfig}  \begin{document}  \begin{figure} \captionsetup[subfigure]{width=2in} \begin{minipage}[t][4em][s]{.5\textwidth} \subfloat[First]{ %\begin{subfigure}[b]{\textwidth} \begin{tikzpicture}[every node/.style={circle, draw, scale=1.0, fill=gray!50}, scale=1.0, rotate = 180, xscale = -1]  \node (1) at (0, 0) {$a$}; \node (2) at (3.0, 0) {$s$}; \node (3) at (4.5, 0) {$s'$}; \node (4) at (7.5, 0) {$t'$}; \node (5) at (9.0, 0) {$t$}; \node (6) at (12.0, 0) {$b$};   \draw[-&gt;] (1) -- (2); \draw[-&gt;] (2) -- (3); \draw[-&gt;] (3) -- (4); \draw[-&gt;] (4) -- (5); %\draw (8) -- (7); \draw[-&gt;] (5) -- (6);  \end{tikzpicture} %\label{fig:sto} } %%\qquad % %\bigskip % \subfloat[Second]{ \label{fig:st} %\begin{subfgure}[b]{\textwidth} \begin{tikzpicture}[every node/.style={circle, draw, scale=1.0, fill=gray!50}, scale=1.0, rotate = 180, xscale = -1]  \node (1) at (0, 0) {$a$}; \node (2) at (3.0, 0) {$s$}; \node (3) at (4.5, 0) {$s'$}; \node (4) at (7.5, 0) {$t'$}; \node (5) at (9.0, 0) {$t$}; \node (6) at (12.0, 0) {$b$};   \draw[-&gt;] (1) -- (2); \draw[thick, dashed, -&gt;] (2) to[out=-100,in=-150] (1); %\draw (3) -- (2); \draw[-&gt;] (3) -- (4); \draw[thick, dashed, -&gt;] (4) to[out=-100,in=-150] (3); %\draw (5) -- (4); \draw[thick, dashed, -&gt;] (2) to[out=-250,in=-350] (4); \draw[thick, dashed, -&gt;] (3) to[out=100,in=150] (1);     %\draw (8) -- (7); \draw[-&gt;] (5) -- (6); \draw[thick, dashed, -&gt;] (6) to[out=-100,in=-150] (5);   \end{tikzpicture} } \end{minipage} \begin{minipage}[t][4em][s]{0.5\textwidth} \subfloat[Third]{ %\begin{subfigure}[b]{\textwidth} %\centering \begin{tikzpicture}[every node/.style={circle, draw, scale=1.0, fill=gray!50}, scale=1.0, rotate = 180, xscale = -1]  \node (1) at (0, 0) {$a$}; \node (2) at (3.0, 0) {$t$}; \node (3) at (4.5, 0) {$t'$}; \node (4) at (7.5, 0) {$s'$}; \node (5) at (9.0, 0) {$s$}; \node (6) at (12.0, 0) {$b$};   \draw[-&gt;] (1) -- (2); \draw[-&gt;] (2) -- (3); \draw[-&gt;] (3) -- (4); \draw[-&gt;] (4) -- (5); %\draw (8) -- (7); \draw[-&gt;] (5) -- (6);   \end{tikzpicture} } %%\qquad % \subfloat[Fourth]{ \label{fig:ts} %\begin{subfigure} \begin{tikzpicture}[every node/.style={circle, draw, scale=1.0, fill=gray!50}, scale=1.0, rotate = 180, xscale = -1]  \node (1) at (0, 0) {$a$}; \node (2) at (3.0, 0) {$t$}; \node (3) at (4.5, 0) {$t'$}; \node (4) at (7.5, 0) {$s'$}; \node (5) at (9.0, 0) {$s$}; \node (6) at (12.0, 0) {$b$};   \draw[-&gt;] (1) -- (2); \draw[thick, dashed, -&gt;] (4) to[out=-100,in=-150] (1); %\draw (3) -- (2); \draw[-&gt;] (3) -- (4); \draw[thick, dashed, -&gt;] (5) to[out=100,in=150] (1); %\draw (5) -- (4); \draw[thick, dashed, -&gt;] (2) to[out=100,in=150] (5); \draw[thick, dashed, -&gt;] (4) to[out=-100,in=-160] (2);   %\draw (8) -- (7); \draw[-&gt;] (5) -- (6); \draw[thick, dashed, -&gt;] (6) to[out=100,in=150] (3);  \end{tikzpicture} } \end{minipage} \end{figure} \end{document} maximum subarray of an array with integers