Я пытаюсь сделать оба этих вывода, если операторы выводятся, если true.
Например, если я введу:
cat
car
Я хочу, чтобы он вывел:
Cat and Car are both the same length.
Cat and Car both start with C.
Прямо сейчас я получаю только Первый вывод
Вот код:
import java.util.Scanner; // Import the Scanner class
public class Main
{
public static void main(String[] args) {
System.out.println("input words");
String myObj, myObj1;
Scanner sc = new Scanner(System.in); // Create a Scanner object
myObj = sc.nextLine(); // String Input
myObj1 = sc.nextLine(); // String Input
if(myObj.length() == myObj1.length()){ // System check for String Length
System.out.println( myObj + " and " + myObj1 + " are the
same length.");
}
if ((myObj1.charAt(0) == 'C') && (myObj.charAt(0) == 'C')){
System.out.println(myObj + " and " + myObj1 + " start with C." );
} // Output if both start with C