[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 == ...
随机推荐
- Spark RDD Transformation 简单用例(三)
cache和persist 将RDD数据进行存储,persist(newLevel: StorageLevel)设置了存储级别,cache()和persist()是相同的,存储级别为MEMORY_ON ...
- jquery <img> 图片懒加载 和 标签如果没有加载出图片或没有图片,就显示默认的图片
参考链接:http://www.jq22.com/jquery-info390 或压缩包下载地址:链接:http://pan.baidu.com/s/1hsj8ZWw 密码:4a7s 下面是没有 ...
- 无法在Web服务器上启动调试。
Ⅰ x 操作超时 有关详细信息,请单击"帮助" x IIS--应用程序池--找到用到的程序池--回收 2 报这个错误的时候,我的IIS应用程序池只有一个>>> ...
- .NET Core开发日志——视图与页面
当一个Action完成它的任务后,通常需要返回一个实现IActionResult的对象,而最常见的就是View或者ViewResult,所谓的视图对象.那么视图与最终所看到的页面之间的联系又是怎样形成 ...
- SmartStore.Net、NopCommerce 全局异常处理、依赖注入、代码研究
以下是本人最近对NopCommerce和SmartStore.net部分代码的研究和总结,主要集中于:依赖注入.异常处理.对象映射.系统缓存.日志这些方面,供大家参考. NOP 3.8 /// < ...
- POJ 1063 - Flip and Shift
Description This puzzle consists of a random sequence of m black disks and n white disks on an oval- ...
- 查询自己的apple购买历史
https://secure1.store.apple.com/cn/order/list
- gfs故障恢复
GlusterFS更换故障Brick tanzhenchao关注0人评论3918人阅读2017-03-21 09:53:18 1 前言 笔者公司内有一套GlusterFS分布式存储,最近数据分区的 ...
- centos7安装Apache
1.下载安装包wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.gz 2.解压tar zxvf httpd-2.4.37.ta ...
- Instruments之Activity Monitor使用入门
Activity Monitor,官方解释为:(活动监视器)即实时显示CPU.内存和网络的使用情况,记录由虚拟内存大小测量的系统负载.用一句大白话来说,Activity Monitor类似Window ...