标签:style blog http color os java ar div sp
1. 接口只能用public 来修饰
2 http:超文本传输协议 端口 80
smtp:简单邮件传输协议 端口25
ftp 21 ssh 22
3 public int aMethod(){
static int i=0;
i++;
}
编译出错,不能在类中声明静态变量
4 class Super {
public Integer getLenght() { return new
Integer(4); }
}
public class Sub extends Super {
public Long getLenght() { return new Long(5); }
public static void main(String[] args) {
Super sooper = new Super();
Sub sub = new Sub();
System.out.println(sooper.getLenght().toString() + "," +
sub.getLenght().toString() );
}
}
编译失败.---------重定时不能改变返回类型
5
class Parent{ String name="parent_name"; static { System.out.println("parent_static"); } public Parent() { // TODO Auto-generated constructor stub System.out.println("parent_constructor"); } public void method(){ System.out.println("parent"); } public static void smethod(){ System.out.println("parent_1"); } } class Child extends Parent{ String name="child_name"; static { System.out.println("child_static"); } public Child() { // TODO Auto-generated constructor stub System.out.println("child_constructor"); } public void method(){ System.out.println("child"); } public static void smethod(){ System.out.println("child_1"); } } public class Test5 { public static void main(String[] args) { Child c=new Child(); System.out.println("---------------"); Parent p=new Parent(); System.out.println("------------------"); p.method(); System.out.println("--------------"); c.method(); System.out.println("--------------"); Parent ddd=new Child(); System.out.println("--------------"); System.out.println(ddd.name); ddd.method(); } }
标签:style blog http color os java ar div sp
原文地址:http://www.cnblogs.com/csxf/p/3985560.html