[Java in NetBeans] Lesson 05. Method/function
这个课程的参考视频和图片来自youtube。
主要学到的知识点有:
- Define a method:(motivation: write one time, but use it many times)

- Access: public, private, protected
- public: Any other class can access a public field or method. (Further, other classes can modify public fields unless the field is declared as final.)
- private: Only current class can access.
- protected: Accessible within all classes in the same package and within subclasses in other packages.
2. Declaration: static
- static: methods can be called without declaring an object of the class first.
3. Return type: void, int, double, char, String, boolean.
- void: the method has no return value.
4. Method name:
- Good name rule: Spell out things where possible
Lower case, second work on is capitalized, e.g.
thisIsAFunction()
5. Parameters:
- Variable Scope Rule: Variable or method parameter only exists inside the method body.
- When pass the parameters, only pass the value. That is why when we declare a field in a class, will start with "_", to distinguish variables with the local variable here.
- Good paramether name rule: Spell out things where possible
Lower case, second work on is capitalized, e.g.
numberRuns - If it is final : All caps with underscores, e.g.
THIS_IS_A_CONSTANT
6. Method body:
- in the block { ... }
- Good block format rule : Indent at 3 space
More rules about naming and format, can refer [Java] public, private, final and basic rules for naming.
[Java in NetBeans] Lesson 05. Method/function的更多相关文章
- [Java in NetBeans] Lesson 07. JavaDoc and Unit Tests
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. organize code into packages Create a package if want to make th ...
- [Java in NetBeans] Lesson 00. Getting Set-up for Learning Java
这个课程的参考视频在youtube. 主要学到的知识点有: set up needs Java SE JDK, NetBeans IDE class name should be the same l ...
- [Java in NetBeans] Lesson 15. Sorting and Searching.
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Build in functions in java.util.Collections Need to implement a co ...
- [Java in NetBeans] Lesson 06. Custom classes
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Constructors: A special method called when an object of the class ...
- [Java in NetBeans] Lesson 04. Class / Objects
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Class: Blueprint for an object. (e.g. dog is a class) Object: cust ...
- [Java in NetBeans] Lesson 01. Java Programming Basics
这个课程的参考视频在youtube. 主要学到的知识点有: Create new project, choose Java Application. one .jar file/ package(.j ...
- [Java in NetBeans] Lesson 17. File Input/Output.
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...
- [Java in NetBeans] Lesson 16. Exceptions.
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...
- [Java in NetBeans] Lesson 09. Switch / If-Else Ladder
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Nested If-else statement (if-else ladder) /** * 90 and above == ...
随机推荐
- js函数 test.caller 谁在调用test函数
返回调用指定函数的函数. function test() { if (test.caller === null) console.log('test 函数在全局调用'); // 获取调用 test函数 ...
- PHP计算两个经纬度地点之间的距离
/** * 求两个已知经纬度之间的距离,单位为米 * * @param lng1 $ ,lng2 经度 * @param lat1 $ ,lat2 纬度 * @return float 距 ...
- CodeForces - 754D
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring s ...
- 浏览器下载Excel,直接打开显示乱码...
情景: 浏览器中点击下载文件有两个选项:[打开][下载] [打开]之后,提示["文件.xlsx"的文件格式和扩展名不匹配.文件可能已损坏或不安全.除非您信任其来源,否则请勿打开.是 ...
- LUA 语言易混点
--代码: tab1 = { key1 = "val1", key2 = "val2","val2", "val3" , ...
- [No0000FC]C# 预处理器指令
预处理器指令指导编译器在实际编译开始之前对信息进行预处理. 所有的预处理器指令都是以 # 开始.且在一行上,只有空白字符可以出现在预处理器指令之前.预处理器指令不是语句,所以它们不以分号(;)结束. ...
- 一道与时间差有关的SQL面试题
题目: 一组通话记录(总共500万条):ID 主叫号码 被叫号码 通话起始时间 通话结束时间 通话时长1 98290000 0215466546656 2007-02-01 09:49:53.000 ...
- https://pypi.org/project/py-mysql2pgsql/
https://packages.ubuntu.com/trusty/postgresql-server-dev-9.3 所以使用下面的命令即可安装python-dev: yum install py ...
- AD采集问题
在调试AD采集时想问的一些问题 1.电路原理图中的VSS是什么意思? 2.电路原理图中的VDD是什么意思? 3.电路原理图中的VREF+和VREF-是什么意思? 4.电路原理图中的VBAT是用来干什么 ...
- jquery.axios无刷新机制删除
思路:无刷新机制就是不用的刷新动作 ,用前端html语法删除和后端的数据库删,同时删除达到效果 除操作,来实现无刷洗的方法