[Java in NetBeans] Lesson 04. Class / Objects
这个课程的参考视频和图片来自youtube。
主要学到的知识点有:
- Class: Blueprint for an object. (e.g. dog is a class)
- Object: custom variables contain state an behavior. (e.g. a two-year old husky is an object of a class dog, it's age is 2, and behavior is bark. then it will have methods like "bark()", "eat(food)")
Define an object:
- If we want to use the classes defined in Java, like Scanner, Random . Then need to use import method to import the class libraries. ("Ctrl + Shifl + i "will automatic import/unimport the packages can be refered) Might also need to import the packages of others or packages in other projects.
import java.util.Random;
- Show javadoc will help you to understand how to use the class or method. This is an example of the Random class we just import above.
// Generator a random number between 0 - 9 Random generator = new Random();
int i = generator.nextInt(10);
- Reverse a string use StringBuilder.
String forward = "This is a test";
StringBuilder sb = new StringBuilder();
sb.append(forward);
// StringBuilder sb = new StringBuilder(forward); is the same like last two lines.
String reverseString = sb.reverse().toString();
System.out.println(reverseString); // System output result will be:
// !tset a si sihT - Math.PI will present pi which is 3.14.... in math. ("Tab" is also our friend to see methods that we can use, so press "Tab" after Math.)
double circ = 2 * Math.PI * radius;
[Java in NetBeans] Lesson 04. Class / Objects的更多相关文章
- [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 07. JavaDoc and Unit Tests
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. organize code into packages Create a package if want to make th ...
- [Java in NetBeans] Lesson 01. Java Programming Basics
这个课程的参考视频在youtube. 主要学到的知识点有: Create new project, choose Java Application. one .jar file/ package(.j ...
- [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 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 14. ArrayList and Collections
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Collection: container that contians objects. 2. Difference betw ...
- [Java in NetBeans] Lesson 09. Switch / If-Else Ladder
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: 1. Nested If-else statement (if-else ladder) /** * 90 and above == ...
- [Java in NetBeans] Lesson 06. Custom classes
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: Constructors: A special method called when an object of the class ...
随机推荐
- Django----ModelFrom
ModelForm a. class Meta: model, # 对应Model的 fields=None, # 字段 exclude=None, # 排除字段 labels=None, # 提示信 ...
- DB2常用函数详解(一):字符串函数
VALUE函数 语法:VALUE(EXPRESSION1,EXPRESSION2) VALUE函数是用返回一个非空的值,当其第一个参数非空,直接返回该参数的值,如果第一个参数为空,则返回第一个参数的值 ...
- HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...
- [No000011A]Office Excel设置显示日期与星期
设置excel日期格式,自定义,yyyy-mm-dd 上午/下午 hh:mm:ss AM/PM dddd aaaa
- 解决sudo: npm: command not found
sudo ln -s /opt/node-v11.4.0/bin/npm /usr/bin/npm sudo ln -s /opt/node-v11.4.0/bin/node /usr/bin/nod ...
- JQuery中数组的创建与使用
一.创建数组的方式: 1.定义并赋值 var str = ['java', 'php', 'c++', 'c#', 'perl', 'vb', 'html', 'css']; 2.用{}定义后赋值: ...
- 使用double无法得到数学上的精确结果的原因及为何不能用double来初始化BigDecimal
使用double无法得到数学上的精确结果的原因: double类型的数值占用64bit,即64个二进制数,除去最高位表示正负符号的位,在最低位上一定会与实际数据存在误差(除非实际数据恰好是2的n次方) ...
- 关于数据库DML、DDL、DCL区别
总体解释:DML(data manipulation language): 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据 ...
- 洛谷P3041 视频游戏的连击Video Game Combos [USACO12JAN] AC自动机+dp
正解:AC自动机+dp 解题报告: 传送门! 算是个比较套路的AC自动机+dp趴,,, 显然就普普通通地设状态,普普通通地转移,大概就f[i][j]:长度为i匹配到j 唯一注意的是,要加上所有子串的贡 ...
- import Vue form 'vue’的意思
1.import Vue form ‘vue’ 写全的话是import Vue from ‘…/nodemouls/vue/list/vue.js’: 此时在webpack.base.conf.js中 ...