示例#1
0
 public static void main(String[] args) {
   ApplicationContext context =
       new ClassPathXmlApplicationContext(
           "org/kasource/kaevent/example/spring/annotations/channel/channel-context.xml");
   Thermometer thermometer = (Thermometer) context.getBean("thermometer");
   thermometer.run();
 }
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    Thermometer thermo = new Thermometer();
    String doItAgain = "y";

    while (doItAgain.equals("y") || doItAgain.equals("Y")) {
      System.out.print("\nEnter degrees Fahrenheit: ");
      thermo.setFahrenheit(reader.nextDouble());
      // Consume the trailing newline
      reader.nextLine();
      System.out.println("The equivalent in Celsius is " + thermo.getCelsius());
      System.out.print("\nDo it again (y/n)? ");
      doItAgain = reader.nextLine();
    }
  }