[java]代码库
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String name = scan.next();
String sex = scan.next();
int age = scan.nextInt();
Person p = new Person(name,sex,age);
p.print();
scan.close();
}
}
class Person
{
private String name;
private String sex;
private int age;
public Person(String n,String s, int a)
{
name = n;
sex = s;
age = a;
}
public String getname()
{
return name;
}
public String getsex()
{
return sex;
}
public int getage()
{
return age;
}
public void setName(String n)
{
name = n;
}
public void setSex(String s)
{
sex = s;
}
public void setAge(int a)
{
age = a;
}
public void print()
{
System.out.println("name:"+name+"; sex:"+sex+"; age:"+age);
}
}