Discuss / Java / 作业

作业

Topic source

刘晋呈php

#1 Created at ... [Delete] [Delete and Lock User]
public class HelloWorld 
{
	 public static void main(String[] args)
	 {
		 Person ming = new Person("xiaoming",20);
		 System.out.println("name is" + ming.getName()+"; age is" + ming.getAge());
	 }
}

class Person
{
	private String name;
	private int age;
	//构造方法
	public Person(String name,int age)
	{
		this.name = name;
		this.age = age;
	}
	
	public String getName()
	{
		return this.name;
	}
	public int getAge()
	{
		return this.age;
	}
}

  • 1

Reply