F
ff_ff
Unregistered / Unconfirmed
GUEST, unregistred user!
public class Student1
{
private int age;
public void setAge(int s_age)
{
if (s_age<10)
{
age=10;
}
if (s_age>100)
{
age=100;
}
else
{age=s_age;}
}
public int getAge()
{
return age;
}
}
class Student1Test
{
public static void main(String[]args)
{
Student1 a =new Student1();
// a.setAge(110);
a.setAge(9);
// a.setAge(56);
System.out.println(a.getAge());
}
}
就是这段代码setAge(9)了,可是出来结果是9(我认为应该是10),如果setAge(110)出来结果就是100;
谁告诉俺是怎么回事?
{
private int age;
public void setAge(int s_age)
{
if (s_age<10)
{
age=10;
}
if (s_age>100)
{
age=100;
}
else
{age=s_age;}
}
public int getAge()
{
return age;
}
}
class Student1Test
{
public static void main(String[]args)
{
Student1 a =new Student1();
// a.setAge(110);
a.setAge(9);
// a.setAge(56);
System.out.println(a.getAge());
}
}
就是这段代码setAge(9)了,可是出来结果是9(我认为应该是10),如果setAge(110)出来结果就是100;
谁告诉俺是怎么回事?