My code fails the "If the two strings are identical, dispay " The numbers are identical" " criterion. Help please?
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
String first_name = scan.nextLine();
String second_name = scan.nextLine();
if ( first_name == second_name ){
System.out.println("The names are identical");
} else if ( first_name.length() == second_name.length()){
System.out.println("The names are the same length");
} else {
}
}
package com.codegym.task.task04.task0421;
/*
Jen or Jen?
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
String first_name = scan.nextLine();
String second_name = scan.nextLine();
if ( first_name == second_name ){
System.out.println("The names are identical");
} else if ( first_name.length() == second_name.length()){
System.out.println("The names are the same length");
} else {
}
}
}