int count; count = getCount(); // a method defined in the program if (count < 0) { System.out.println("Error: count value is negative."); }else { System.out.println("There will be " + count + " people for lunch today."); }//源代码片段来自云代码http://yuncode.net