this 代表当前对象 当前对象指的是这个类例如Telphone 主要作用是赋值 不理解的不要过于纠结 继续向后面学习 然后时不时的回头看基础 当时不能理解的 突然间就会豁然开朗的
2018-07-31
package com.transpotation;
public class Boat extends Transport {
String name = "小船";
String way = "海洋";
int num = 10;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
public class Boat extends Transport {
String name = "小船";
String way = "海洋";
int num = 10;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
2018-07-27
package com.transpotation;
//轮船
public class Ship extends Transport{
String name = "轮船";
String way = "海洋";
int num = 100;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
//轮船
public class Ship extends Transport{
String name = "轮船";
String way = "海洋";
int num = 100;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
2018-07-27
package com.transpotation;
//飞机
public class Plane extends Transport{
String name = "飞机";
String way = "天空";
int num = 400;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
//飞机
public class Plane extends Transport{
String name = "飞机";
String way = "天空";
int num = 400;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
2018-07-27
package com.transpotation;
//长途大巴
public class Car2 extends Transport{
String name = "长途大巴";
String way = "陆地";
int num = 40;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
//长途大巴
public class Car2 extends Transport{
String name = "长途大巴";
String way = "陆地";
int num = 40;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
2018-07-27
package com.transpotation;
//小汽车
public class Car1 extends Transport{
String name = "小汽车";
String way = "陆地";
int num = 5;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
//小汽车
public class Car1 extends Transport{
String name = "小汽车";
String way = "陆地";
int num = 5;
public void run(String trans){
System.out.println(name+"能在"+ way+"拉"+num+"人");
}
}
2018-07-27
package com.transpotation;
//父类
public class Transport {
String name,way;
int num;
public void run(String trans) {
// TODO Auto-generated method stub
System.out.println("这是父类!");
}
}
//父类
public class Transport {
String name,way;
int num;
public void run(String trans) {
// TODO Auto-generated method stub
System.out.println("这是父类!");
}
}
2018-07-27