class ErrorMsg
{
/* The invisible default constructor is for our convenience.
   It takes no argument.
   It creates the object and does not initialize values.
   However, the newly created object does INHERIT all the methods and instance variable of that class.
*/
  // separate the "user interface" of error string from the internal array
  String[] msgs =
  {
    "Output Error",
    "Input Error",
    "Disk Full",
    "Index Out-Of-Bounds"
  };

  // Return the error message by passing runtime arg to the element reference.
  String getErrorMsg(int i)
  {
	System.out.println("array length is : " + msgs.length);
   // System.out.println("4th element is : " + msgs["apple"]);

    if(i >=0 & i < msgs.length)
      return msgs[i];
    else
      return "Invalid Error Code";
  }
}

class ArrayOfStringsErrMsg
{
  public static void main(String[] args)
  {
    ErrorMsg err = new ErrorMsg(); // call the constructor to instantiate an object of type ErrorMsg with the reference err
    System.out.println(err.getErrorMsg(0));
    System.out.println(err.getErrorMsg(2));
    System.out.println(err.getErrorMsg(19));
  }
}
