public class transports(){
public void carry(){
system.out.println("交通工具可以载人");
}
public class car extends transports
public void land(){
system.out.println("汽车在陆地上行驶");}
}
Transports one = new transports();
public void carry(){
system.out.println("交通工具可以载人");
}
public class car extends transports
public void land(){
system.out.println("汽车在陆地上行驶");}
}
Transports one = new transports();
2016-04-04
public class Demo01 {
static int score1 = 86;
static int score2 = 92;
public static int sum() {
int sum=score1 + score2;
return sum;
}
public static void main(String[] args) {
int allScore = sum();
System.out.println("总分:" + allScore);
}
}
static int score1 = 86;
static int score2 = 92;
public static int sum() {
int sum=score1 + score2;
return sum;
}
public static void main(String[] args) {
int allScore = sum();
System.out.println("总分:" + allScore);
}
}
2016-04-03
最后一步修改了newScreen的限制条件(if else)语句后,要把原来的那句screen=newScreen删除掉,否则相当于没有限制
2016-04-02
这个和数据的类型转化类似
//正常赋值,小转大
byte a =127;
int b = a;
//会报错,大转小,int转换成byte会损失精度,一个道理
int c = 168;
byte d = c;
//正常赋值,小转大
byte a =127;
int b = a;
//会报错,大转小,int转换成byte会损失精度,一个道理
int c = 168;
byte d = c;
2016-04-02
public class HelloWorld {
static int score1 = 86;
static int score2 = 92;
public static int sum() {
sum = score1 + score2;
}
public static void main(String[] args) {
int allScore = sum();
System.out.println("总分:" + allScore);
}
}
static int score1 = 86;
static int score2 = 92;
public static int sum() {
sum = score1 + score2;
}
public static void main(String[] args) {
int allScore = sum();
System.out.println("总分:" + allScore);
}
}
2016-04-01
多态的类型转换,向上类型转换(隐藏/自动类型转换),是小类型转换到大类型
向下类型转换(强制类型转换),是大类型转换成小类型
instanceof运算符,来解决引用对象的类型,避免类型转换的安全性问题。
向下类型转换(强制类型转换),是大类型转换成小类型
instanceof运算符,来解决引用对象的类型,避免类型转换的安全性问题。
2016-04-01
对象:客观存在的事物;
类:把对象抽象出来,它是指拥有相同属性的行为和特征的某一类型。
属性:对象的各种特征。
方法:对象能做的事情。
类:把对象抽象出来,它是指拥有相同属性的行为和特征的某一类型。
属性:对象的各种特征。
方法:对象能做的事情。
2016-04-01