标签:private package public return
package ctgu.java; public class TestPerson { public static void main(String[] args) { Person p = new Person(); p.steAge(120); //p.steAge(150); System.out.println(p.getAge()); } } class Person{ private int age ; public int getAge(){ return age ; } public void steAge(int a){ if(a > 0&& a <=130){ age = a; }else{ //System.out.println("你输入的数据有误"); throw new RuntimeException("你输入的数据有误!"); } } }
标签:private package public return
原文地址:http://9815936.blog.51cto.com/9805936/1604899