title: Write a Java program that reads in two floating-point numbers and tests whether they are the same up to three decimal places
body: <p>Why my flow is going to else part of the if statement</p>
  
  <p>public class Exercise6MatchDecimalValues {</p>
  
  <pre><code>    public static void main(String[] args) throws Exception
      {
          Scanner stream = new Scanner(System.in);
          System.out.println("Input floating point number: ");
          Double input1= stream.nextDouble();
          System.out.println("Input another floating point number: ");
          Double input2 = stream.nextDouble();
          String input1StringDecimal = String.valueOf(input1).split("\\.")[1].substring(0, 3);   //To get the first 3 decimal values
          String input2StringDecimal= String.valueOf(input2).split("\\.")[1].substring(0, 3);  //To get the first 3 decimal values
          String input1StringWhole=String.valueOf(input1).split("\\.")[0];  //To get the whole value
          String input2StringWhole=String.valueOf(input2).split("\\.")[0]; // //To get the whole value
          System.out.println("input1StringWhole"+input1StringWhole);
          System.out.println("input1StringDecimal"+input1StringDecimal);
          System.out.println("input2StringWhole"+input2StringWhole);
          System.out.println("input2StringDecimal"+input2StringDecimal);
  
          if(input1StringDecimal == input2StringDecimal &amp;&amp; input1StringWhole==input2StringWhole) {
              System.out.println("They are same");
          }else
          {
              System.out.println("They are different! ");
          }
  
      }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>Input floating point number: 123.1234
  </code></pre>
  
  <p>Input another floating point number: 123.1234</p>
  
  <p>input1StringWhole   123</p>
  
  <p>input1StringDecimal   123</p>
  
  <p>input2StringWhole   123</p>
  
  <p>input2StringDecimal   123</p>
  
  <p>They are different! </p>