java se web向需要的资料整理1

首先,j2se 建议用editplus来写(因为本身不会很难)

1.思想:封装继承多态

单纯从简单的角度来说:封装就是getset的爪哇豆子。。//口胡的。。其实是java语言编写的可重用的软件组件

(私有成员变量,private int age; public get()/set())

  继承:下面helloworld里的class C,Base,父节点,基(父)类

  多态:子类实例化后把实例化的对象交给父类操控(类似)或者交给接口来传递值。

  EG:Father f = new Son();←class Son extends Father

2.8个基本数据类型,.java文件命名规则

基本类型:byte short int long float double boolean char

     .java文件命名规则 _$+英文开头

3.hello world(加强版)


interface B{

		// this is a interface
		public void bbb();
	}
	class C{

		 this is a BaseA
		public void use(String s){
			if(s.equals("Hello world"))
			System.out.println("yeah,I'm java.Greeting to you");
		}
	}
	public class A extends C implements B{

		// We can use constructor to Say start
		public A(){
			System.out.print("This is a Start.");
			System.out.println("");
		}
		// We should implement bbb method
		public void bbb(){
			this.use("Hello world");
		}
		public static void main(String args[]){
			new A().bbb();
		}
	}

3. new instance(很多名词基于英文讲比较实在,渣英文如有错误,请各位看官指出谢谢。。)

     As we all known,java is a object-oriented language.So if you want to use class,you should instantiate it.eg:helloworld.java--new A()

     But this isn't which we want to do.If class A() has another method.new A().ccc()??

     terrible...So the normal new instance is to give it a handle(a);

     eg: A a = new A(); a.bbb(); a.ccc();


     So helloworld.java main method is modified to:


 public static void main(String args[]){

                //new instance
                A a = new A();
                a.bbb();
            }
                          

             注:本身想用多态但懒(拖走。。)。。。。

             顺便。其实把A改成B就可以了。。。。(打死。。)

4.constructor method,override(overwriting and overloading,this and super)

  member method and constructor method's difference.

  member method has a return object.constructor not.

  member:If you want to use, you should handle.method

  constructor:new class(),it will start to run.

  eg:


class A{
    public A(){
    System.out.println("This is constructor");
    }
    public void aa(){
    System.out.println("This is Member method");
    }
    public static void main(String args[]){
    new A();
    System.out.println("=====================");
    new A().aa();
    }
}

     override:

      1.overwriting

             baseClass B has method aa()

             extendClass A has method aa()

             we use aa() is Class A not Class B.(normal)

       2.overloading

              Class A has two or more constructor,like aa(),aa(String s) etc.

     eg:


 class BaseA{
       public void AA(){
           System.out.println("AA");
       }
   }
   class A extends BaseA{
       public A(){
           System.out.println("overloading with no Parameter");
       }
       public A(String s){
           System.out.println("overloading with String");
       }
       public void AAA(){
           super.AA();
           System.out.println("=================");
           System.out.println("this is overwriting AAA");
           this.AA();
       }
       public void AA(){
           System.out.println("this is overwriting AA");
       }
       public static void main(String args[]){
           new A();// overloading with no Parameter
           System.out.println("===================");
           new A("AA");// overloading with String
           System.out.println("===================");
           new A().AAA();
           /* overloading with no Parameter
            * AA
            * =================
            * this is overwriting AAA
            * this is overwriting AA
            */
           System.out.println("===================");
       }
   }




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值