Java自学-5
说说“some terminologies”
Instance variable
也就是我们常说的“实例变量”,可以设定对象的特征等。
Constructor
在网上看主要翻译为“构造器”?它类似于一种method但是实际并不是method,它决定了怎样去实例化一个类,不确定自己翻译的对不对,还是上英文吧(Determines how to instantiate the class)
Non-static method or Instance Method
如果一个方法会通过一个类的实例来触发,那么这个方法一定就是non-static的了。举个例子
一个方法中给出了几个数据段对应的不同响应,类似于我有3块钱,可以买瓶水;我有5块钱,可以买根烤肠。。。这种需要考虑到“我”的具体情况对应的方法,就一定是非静态的了。
Declaration Instantiation and Assignment
声明、实例化以及分配,这三个术语感觉放在一起说更易理解和记忆一些,举个例子来说吧:
/*if I have a class called Dog*/
Dog smallDog; //this is a declaration, define a smallDog, it has the properties of the Dog class
new Dog(20); //this is a instantiation, it's means that I creat a new Dog class with some settings
Dog smallDog = new Dog(20); //this code contains declaration iinstantiation and assignment, it is the most popular way as well
Invocation
调用,也就是调用其他class中的method,还说dog的例子吧:
smallDog.makeNoise(); //assume we have a method in Dog class called makeNoise, we want to use it in my new class - smallDog, I'll write this code and make it.
英语水平很一般很一般,注释凑活写的英文的被嫌弃就好~