[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 == ...
随机推荐
- jquery <img> 图片懒加载 和 标签如果没有加载出图片或没有图片,就显示默认的图片
参考链接:http://www.jq22.com/jquery-info390 或压缩包下载地址:链接:http://pan.baidu.com/s/1hsj8ZWw 密码:4a7s 下面是没有 ...
- http://linux-mtd.infradead.org/doc/nand.html nand
http://linux-mtd.infradead.org/doc/nand.html
- Mapper 赋值对应实体属性
public static class MapperExtensions { public static TResult MapTo<TResult>(this object self, ...
- 如何打jar包 学习笔记
jar包是由.class文件压缩而成.要查看jar包中的内容,使用压缩工具 解压缩即可.也可以做修改,并重新打成jar包.总结一下最近学到的一些打jar包的方法: 一.DOS下使用jar命令 打jar ...
- html学习_html5 新增标签和属性
html5 新增标签和属性 1.html发展历程(html有很多版本) 2.快捷键生成不同版本(html4.xhtml.html5) 文档类型不同.字符设定 3.常用新标签 (只有html5才识别的标 ...
- python与pycharm安装
1.python install 1.1 下载安装包 - https://www.python.org/downloads 1.2 installl 1.2.1 双击exe安装文件 1.3 如果安装 ...
- hive优化之并行执行任务
1.与Oracle并行技术一样,hive在执行mapreduce作业时也可以执行并行查询.针对于不同业务场景SQL语句的执行情况,有些场景下SQL的执行是需要分割成几段去执行的,而且期间并不全是存在依 ...
- [cloud][sdn] LBaaS/neutron / Octavia
清晰/浅显: http://www.cnblogs.com/sammyliu/p/4656176.html IBM:写的一般般,价值不大 https://www.ibm.com/developerwo ...
- AVD启动报错:Running an x86 based Android Virtual Device (AVD) is 10x faster
1.cmd窗口中输入emulator -avd test 启动AVD时报错: Running an x86 based Android Virtual Device (AVD) is 10x fast ...
- linux popen()函数使用
默认管道只能处理标准输出,不能处理标准错误输出 所以在popen()函数中运行的命令若有标准错误输出,调用者无法捕获 解决办法: 1.将标准错误输出重定向到标准输出2>&1,这样调用者能 ...