I have been given a short task to make a program that is supposed to have an applet that functions basically as a login screen, and that it gets disabled whenever 3 tries have been made. The problem is it always shows that the input is not equal to the username and password that I have pre-set, and I don't know why. x.getText() turns the input into a String, right? But it seems that it is not so. The If-else conditional statement does not seem to be the problem, but it is where the problem happens. The flow of the program skips to the else statement.  I think I have made this work earlier, I can't remember what I did to make it work and to make it not work. LOL. I am using eclipse, JDK 8. (Applets seem to work only on JDK8 and below). Previously, I was using JDK14 but changed it to JDK8 in my compiler and build path, so now Applets work. But could a step in that change have been the cause of the problem?  import java.applet.Applet; import java.awt.*; import java.awt.event.*; import javax.swing.JOptionPane;  public class easy extends Applet implements ActionListener {     Label labelusername = new Label (&quot;Username&quot;);     TextField inputusername = new TextField (&quot;&quot;, 20);     Label labelpassword = new Label (&quot;Password&quot;);     TextField inputpassword = new TextField (&quot;&quot;, 20);     Button buttonlogin = new Button (&quot;Ok&quot;);     int ntries = 0;     String username, password; public void init(){     inputusername.setText(&quot;hello&quot;);     inputpassword.setText(&quot;there&quot;);     inputpassword.setEchoChar('*');     add(labelusername);     add(inputusername);     add(labelpassword);     add(inputpassword);     add(buttonlogin);     buttonlogin.addActionListener(this); }  public void actionPerformed(ActionEvent x) {     if(x.getSource() == buttonlogin) {         ntries++;         System.out.println(inputusername.getText());         System.out.println(inputpassword.getText());         System.out.println(inputusername.getText() + inputpassword.getText());         username = inputusername.getText();         password = inputpassword.getText();                  if(ntries != 3) {             System.out.println(&quot;yow&quot;);             if((inputusername.getText() == &quot;hello&quot;) &amp;&amp; (inputpassword.getText() == &quot;there&quot;)) {                 JOptionPane.showMessageDialog(null, &quot;Password Accepted&quot;);             }else {                 JOptionPane.showMessageDialog(null, &quot;Invalid Password&quot;);             }         }else {             JOptionPane.showMessageDialog(null, &quot;no more tries&quot;);             inputusername.setEditable(false);             inputpassword.setEditable(false);             buttonlogin.setEnabled(false);         }     } } }  EDIT: okay sorry, apparently you have to use .equals when comparing strings.
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 is WebDriver instance declared static in Page Object model structure in Selenium? I am a complete newbie in Selenium and java in general. I am trying to use the Page object model with Page factory to create Page object class for the Login page of an application. I am reading lot of sample code on the web tutorials and there the "Webdriver"  reference is delared as "static". Is it that other classes can use the Base class driver instance?  package com.test.login;  import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy;  public class LoginPage {      **public static WebDriver driver = null;**      public LoginPage(WebDriver driver) {         this.driver = driver;            PageFactory.initelements(driver, this);     }      @FindBy(xpath = "//input[contains(@id,'username')]")     public WebElement User_ID      @FindBy(xpath = "//input[contains(@id,'password')]")     public WebElement Password;      @FindBy(xpath = "//input[contains(@id,'login')]")     public WebElement Login_Button;   LoginTestClass.java  public class LoginPageTest{     WebDriver driver;     LoginPage loginpage = PageFactory.initElements(Login.class); XIV pages in page counts? Is it possible to make biblatex output page counts for both the regular pages and the roman-numbered pages, for example:     Cook, Theodore Andrea. The Curves of Life : Being an Account of Spiral Formations and Their Application to Growth in Nature, to Science and to Art; with Special Reference to the Manuscripts of Leonardo da Vinci. — London : Constable and Company, 1914. — xxx + 479 p.   Here there are "30 pages + 478 pages" in total. Thanks! What is wrong with this fake proof $e^i = 1$? $$e^{i} = e^{i2\pi/2\pi} = (e^{2\pi i})^{1/(2\pi)} = 1^{1/(2\pi )} = 1$$  Obviously, one of my algebraic manipulations is not valid. Matrix representation of linear transformation Did Luke attempt to retake the Jedi Temple on Coruscant? After the New Republic gains control of Coruscant through the Galactic Concordance, did Luke Skywalker attempt to reclaim (or even visit) the former and still very much intact Jedi Temple, now converted to be the deceased Emperor's palace?   If Luke is so insistent on saving a tree just because it belongs to the Jedi and the Empire stole it, then shouldn't reclaiming the Jedi Temple be even higher priority?  If he did, is he aware of the Sith shrine beneath it? Which is something even Yoda does not know. And if he didn't, why didn't he? What is the best book to learn probability? Question is quite straight... I'm not very good in this subject but need to understand at a good level. $\gcd(a,b)=1, x^a = y^b\Rightarrow x = n^b$, $ y = n^a$ for an integer $n$. If $ a$, $ b$, $ x$, $ y$ are integers greater than $1$ such that $ a$ and $ b$ have no common factor except $1$ and $ x^a = y^b$ show that $ x = n^b$, $ y = n^a$ for some integer $ n$ greater than $1$.  I started this way: $x^a=y^b$ $=&gt;$ $x=y^{b/a}=(y^{1/a})^b$. Thus $x$ is an integer, and so is $y^{1/a}$, so $y=n^a$ for some integer $n$ greater than $1$. Then from the given relation, we get $x=n^b$.   I am not very convinced with my solution, as I feel I did some mistake. Can anyone point out where the mistake is? Any other solution is also welcome :) I have created screenShot() method to take the screenshot of the web page. When I used this method in my code first time it will capture the screen and it will save the image with image1 name. When I used the same method screenShot() to capture screens for other pages with the use of this.screenShot(); this will again capture the current web page screen but it stores With the same name image1 in the same folder (which overrides to previously captured screen image1).  Now, I have to take screenshots for the number of web pages &amp; want to store it into the same folder with different names like image1, image2, image3...etc. by using the same method screenShot().  public void screenShot() throws IOException, InterruptedException {     File scr = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);     File dest = new File("filPath/image1.png");     FileUtils.copyFile(scr, dest); }   Any workaround to achieve this scenario? How do I find the particular solution of this second order inhomogenous differential equation? (Using undetermined coefficients).  $y''-4y'+5y = 4e^{2x} (\sin x)$  I can find the generel homogenous solutions but I need help for the particular. When $z\neq 0$, $\arg z$ is defined to be the set $\{\theta \in \mathbb{R} : z=|z|e^{i\theta}\}$.  What if $z=0$? Usually does one leave the argument of $0$ undefined? Or is $\arg 0 = \mathbb{R}$? Prove that $x-1$ divides $x^n-1$ In algebra &amp; polynomials, how do we prove that $$x-1 \mid x^n -1?$$ Proving Pascal's identity So I came across Pascal's identity: Prove that for any fixed $r\geq 1$, and all $n\geq r$, $$ \binom{n+1}{r}=\binom{n}{r}+\binom{n}{r-1}. $$  I know you can use basic algebra or even an inductive proof to prove this identity, but that seems really cumbersome. I was wondering if anyone had a "cleaner" or more elegant way of proving it. For example, I think the following would be a decent combinatorial proof.   Proof: Let $S$ be a set with $n+1$ elements, and consider some fixed $x\in S$. There are $\binom{n+1}{r}\;\; r$-subsets of $S$--count them according to whether or not they contain $x$: there are $\binom{n}{r}$ not containing $x$, (each formed by choosing $r$ of the remaining $n$ elements in $S\setminus\{x\}$), and there are $\binom{n}{r-1}\;\; r$-sets containing $x$, (each formed by selecting an additional $r-1$ elements in $S\setminus\{x\}$).   Is that right? Are there any other efficient ways of doing it? My input file is,  ami21 ami65 ami67 ami66 ami88 ami76 ami29 ami55  ami54 ami32   Using a single command line I need the output as,  ami22 ami66 ami68 ami67 ami89 ami77 ami30 ami56 ami55 ami33   I used the command  awk -vRS=ami '{$0=$0+1;ORS=RT}++n' inputfile &gt; outputfile   but I got the outputfile as ami21ami65ami67ami66ami88ami76ami29ami55ami54ami32  i.e. all strings are written in same line and without space. Could anyone suggext me some better command line. What do I need for extreme macro photography? How to write (La)TeX (with parentheses) [or any other TeX-related logo] I'm looking after a macro to write the (La)TeX logo (with parentheses), i.e. something similar to \TeX, \LaTeX, but where the output includes ()'s. I am trying to perform stepwise regression for variable selection in R.  In matlab, the stepwisefit function is able to work in n &lt; p problems. Trying to use step() for such problems i get the error message AIC is -infinity for this model, so 'step' cannot proceed. Is there a way to modify parameters so i can use step function? Translation of these Cirth runes What is the translation of what's written below?  I think it may be the poem of the One Ring, but I'm not sure. Compactness of  Multiplication Operator on $L^2$ Suppose we have an bounded linear operator A that operates from $L^2([a,b]) \mapsto L^2([a,b])$.  Now suppose that $A(f)(t) = tf(t)$.    Is A compact?  Edit: I know $A = A^*$ but I'm not really sure how to start on this.  It's not homework, just summer fun :D Testing for linear dependence among the columns of a matrix I have a correlation matrix of security returns whose determinant is zero. (This is a bit surprising since the sample correlation matrix and the corresponding covariance matrix should theoretically be positive definite.)  My hypothesis is that at least one security is linearly dependent on other securities. Is there a function in R that sequentially tests each column a matrix for linear dependence?  For example, one approach would be to build up a correlation matrix one security at a time and calculate the determinant at each step. When the determinant = 0 then stop as you have identified the security who is a linear combination of other securities.  Any other techniques to identify linear dependence in such a matrix are appreciated. Could a constant function be considered increasing? Given the definition of an increasing function as a function $f:E\to\mathbb{R}$, where $E$ is nonempty such that $x_1,x_2\in E$ and $x_1&lt;x_2$ imply $f(x_1)\leq f(x_2)$, then couldn't, for example, $f(x)=-1$ considered increasing? Since the inequality is not a strict inequality.