public class Testclass //java 的oo思想介绍 { class people { int age; int high; String name; String hello(){ return "hello,i am"+name; }}public static void main(String[] args) { people me= new people(); people you= new people(); me.age=23; me.high=178; me.name="caoji"; you.age=22; you.high=167; you.name="tlf"; System.out.println("我的年龄是"+me.age+",我的身高是"+me.high+",我的名字是"+me.name); System.out.println("你的年龄是"+you.age+",你的身高是"+you.high+",你的名字是"+you.name); System.out.println(me.hello()); System.out.println(you.hello()); } }//试一试
要把你的类(或程序)放在classpath下
{
class people
{
int age;
int high;
String name;
String hello(){ return "hello,i am"+name;
}}public static void main(String[] args)
{
people me= new people();
people you= new people();
me.age=23;
me.high=178;
me.name="caoji";
you.age=22;
you.high=167;
you.name="tlf";
System.out.println("我的年龄是"+me.age+",我的身高是"+me.high+",我的名字是"+me.name);
System.out.println("你的年龄是"+you.age+",你的身高是"+you.high+",你的名字是"+you.name);
System.out.println(me.hello());
System.out.println(you.hello());
}
}//试一试