本帖最后由 伍艳雄 于 2014-1-1 17:37 编辑
- class Preson {
- private int age;
- private int score;
- Preson(int age,int score) {
- if (this.age>0&&this.age<130) {
- this.age=age;
- System.out.println("age="+age);
- }else {
- System.out.println("nono..");
- }
- if (this.score>=0&&this.score<=150) {
- this.score=score;
- System.out.println("score="+score);
- }else {
- System.out.println("nononono.");
- }
- }
- }
- class Test11 {
- public static void main(String[] args) {
- new Preson(-20,-90);//当我输入两个负数时,应该全是no,,,,,,但结果age可以判断,但score就直接打出负数了,..这怎么解决
- }
- }
复制代码 怎么只判断第一个,而第二个直接打印了
|