import java.util.Scanner;

public class HelloWorld2
  /** HelloWorld2 introduces the String class with methods
    * length and charAt
    * also the "Scanner Bug" was explained.
    * and other methods such as nextLine() nextInt() were shown.
    * */
{
  public static void main(String[] args)
  {
    String name;
    Scanner in = new Scanner(System.in);
    
    System.out.print("What is your age? ");
    int age = in.nextInt();
    
    in.nextLine();  // ignore the newline in input buffer
    
    System.out.print("What is your name? ");
    name=in.nextLine();
   
    System.out.println("Hello " + name + " age: " + age);
    System.out.println("The length of your name is " + name.length());
    
    System.out.println("Are you coming to tonight's party? Y/N");
    String answer = in.nextLine();
    char ch = answer.charAt(0);  // this should first character in answer and put it into ch
    System.out.println("You answered: " + ch);
    // int x;
    // x.someMethod(); x is a variable, cannot use DOT on variable
    // String objects are OBJECTS so we can use the DOT operator
  }
}

