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

主要学到的知识点有:

  • Constructors: A special method called when an object of the class is created
  • property pattern and encapsulation(封装): hide the implementation details from the user, so when the class is been inherited, only the methods, but not the members.
  • this: simply refers to the current class.
  • Also allow us to call other constructor in one constructor
public class Foo
{
private int _x; // if class members, and not public, start with underscore. public Foo()
{
this(1);
} public Foo(int x)
{
_x = x;
}
}
  • Overload: The method with different parameter but same method name. (for example, the constructors. Java will automatic search for the constructors that fits the parameters passed in)

e.g. Foo foo = new Foo(8); will automatic search for the second constructor "public Foo(int x)".

  • Every class should have a constructor. But the body can be empty.
  • Declare variables as private as possible. Can create getter and setter for the variables to control access to private variables.  based on the encapsulation(封装) concept.
  • Initialize all private variables in constructor. (if not, make them final)
  • this disambiguates method parameters from private members, but will name the members with _(unless it is public). Below is an example without "_".
public class Foo
{
private int x; public Foo()
{
this(1);
} public int setX(int x)
{
this.x = x;
}
}
  • Use get/set methods to control access to private variables.

[Java in NetBeans] Lesson 06. Custom classes的更多相关文章

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

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

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

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

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

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

  4. [Java in NetBeans] Lesson 05. Method/function

    这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Define a method:(motivation: write one time, but use it many times ...

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

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

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

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

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

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

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

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

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

随机推荐

  1. SharePoint 2013自定义Providers在基于表单的身份验证(Forms-Based-Authentication)中的应用

    由于项目的需要,登录SharePoint Application的用户将从一个统一平台中获取,而不是从Domain中获取,所以需要对SharePoint Application的身份验证(Claims ...

  2. Ubuntu 16.04 编译OpenCV 问题解决stdlib.h: No such file or directory

    https://blog.csdn.net/xinyu391/article/details/72867510 https://ask.csdn.net/questions/365969

  3. djiango web 在进入admin的时候出现'set' object is not reversible错误

    解决方案是在你的urls.py 中 把{ } 改为[] 原因不详 治标不治本,并不能改的东西

  4. cc2650-cc2640蓝牙开发准备手记

    1.安装  ti关键库,首先BLE 协议栈,安装那种协议栈,首先你要用哪种库(源代码,官方例子基于哪种用哪个就会好,不然会出现不兼容), 2.然后安装flash_programmer2(有1,.2个版 ...

  5. FutureTask的用法及两种常用的使用场景

    FutureTask可用于异步获取执行结果或取消执行任务的场景.通过传入Runnable或者Callable的任务给FutureTask,直接调用其run方法或者放入线程池执行,之后可以在外部通过Fu ...

  6. Redis的概念及与MySQL的区别

    学了MySQL相关知识后,了解到很多公司都会用mysql+redis互补使用的,今天学习整理一下Redis的相关知识. 首先是Redis和MySQL的区别: MySQL是典型的关系型数据库:Redis ...

  7. MVC 实用架构设计(〇)——总体设计

    〇.目录 一.前言 二.结构图 三.结构说明 一.前言 一直以来都想写这个系列,但基于各种理由(主要是懒惰),迟迟没有动手.今天,趁着周末的空档,终于把系列的目录公布出来了,算是开个头,也给自己一个坚 ...

  8. Fmod使用总结

    1.查询相关文档的地址 http://www.fmod.org/forum/viewtopic.php?f=7&t=15762

  9. hdfs mapreduce hbase

    参考资料:http://www.cnblogs.com/sharpxiajun/p/5585613.html 大数据时代的数据量是超大规模的,传统的关系数据库已经很难存储和管理这些数据了,为了存储海量 ...

  10. Python中的format函数

    format是python2.6新增的一个格式化字符串的方法,相对于老版的%格式方法,它有很多优点. 1.不需要理会数据类型的问题,在%方法中%s只能替代字符串类型 2.单个参数可以多次输出,参数顺序 ...