Variable Name      Value in Memory
            
            
         
         
        
        
         
        
        
        
            
                0     
                1     
                2     
                3     
                4     
                5     
                6     
                7     
                8     
                9     
            
 
            
                a     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
            
            
                b     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
                a     
            
          
        
            
        
        
            
        
        
            empty string
        
        
            empty string
        
        
            
  1  import java.util.Scanner;
  2  
  3  public class OrderTwoCities {
  4    public static void main(String[] args) {
  5      Scanner input = new Scanner(System.in);
  6      
  7      
  8      System.out.print("Enter the first city: ");
  9      String city1 = input.nextLine();
 10      System.out.print("Enter the second city: ");
 11      String city2 = input.nextLine();
 12      
 13      if (city1.compareTo(city2) < 0)
 14        System.out.println("The cities in alphabetical order are " +
 15          city1 + " " + city2);
 16      else
 17        System.out.println("The cities in alphabetical order are " +
 18          city2 + " " + city1);
 19    }
 20  }
            
         
        
        
        
            
 Output