这个课程的参考视频和图片来自youtube

主要学到的知识点有:

  • Define a method:(motivation: write one time, but use it many times)

  1. 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的更多相关文章

  1. [Java in NetBeans] Lesson 07. JavaDoc and Unit Tests

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. organize code into packages Create a package if want to make th ...

  2. [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 ...

  3. [Java in NetBeans] Lesson 15. Sorting and Searching.

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Build in functions in java.util.Collections Need to implement a co ...

  4. [Java in NetBeans] Lesson 06. Custom classes

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Constructors: A special method called when an object of the class ...

  5. [Java in NetBeans] Lesson 04. Class / Objects

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Class: Blueprint for an object. (e.g. dog is a class) Object: cust ...

  6. [Java in NetBeans] Lesson 01. Java Programming Basics

    这个课程的参考视频在youtube. 主要学到的知识点有: Create new project, choose Java Application. one .jar file/ package(.j ...

  7. [Java in NetBeans] Lesson 17. File Input/Output.

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...

  8. [Java in NetBeans] Lesson 16. Exceptions.

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...

  9. [Java in NetBeans] Lesson 09. Switch / If-Else Ladder

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Nested If-else statement (if-else ladder) /** * 90 and above == ...

随机推荐

  1. js中if语句的几种优化代码写法

    UglifyJS是一个对javascript进行压缩和美化的工具,在它的文档说明中,我看到了几种关于if语句优化的方法. 一.使用常见的三元操作符 复制代码 代码如下: if (foo) bar(); ...

  2. 2018ACM-ICPC焦作区域赛【反思总结】

    摸银结束回来,整个人都轻松了. 自CCPC打铁以来的这两个月真的太痛苦了. 俱乐部退役的退役停训的停训,好冷清啊. 前期切题很稳,前四题两个小时1A. 过了四题之后好像心态有点飘,然后开题就慢了,想题 ...

  3. sqlServer自动代码提示功能

    第一种方法: 首先确认 自己的sqlServer2008自身的提示功能有没有被屏蔽了! 打开sqlserver2008 -- 工具 -- 选项 -- 文本编辑器 -- 所有语言 --  勾选 语句结束 ...

  4. nowcoder 211B - 列队 - [(伪·良心贪心)真·毒瘤暴力]

    题目链接:https://www.nowcoder.com/acm/contest/211/B 题目描述 炎热的早上,gal男神们被迫再操场上列队,gal男神们本来想排列成x∗x的正方形,可是因为操场 ...

  5. angular validation 使用总结

    我由于制作登陆界面,用到了angular-validation,结合ng-cookies,实现记住账户密码的功能.文档是https://github.com/hueitan/angular-valid ...

  6. PHP之对象类型

    PHP之object对象 对象初始化 要创建一个新的对象object,使用new语句实例化一个类: 转化为对象 如果讲一个对象转化成对象,它将不会有任何变化.如果其它任何类型的值被转化成对象,将会创建 ...

  7. day0318装饰器和内置函数

    一.装饰器 1.装饰器: 解释:装饰器的本事就是一个函数,不改动主代码的情况下,增加新功能.返回值也是一个函数对象. 2.装饰器工作过程 import time def func(): print(' ...

  8. Calcite - StreamingSQL

    https://calcite.apache.org/docs/stream.html   Calcite's SQL is an extension to standard SQL, not ano ...

  9. Flink - TypeInformation

    Flink 自己创建一套独立的类型系统, 参考, https://ci.apache.org/projects/flink/flink-docs-release-0.10/internals/type ...

  10. python找出数组中第二大的数

    #!usr/bin/env python #encoding:utf-8 ''''' __Author__:沂水寒城 功能:找出数组中第2大的数字 ''' def find_Second_large_ ...