Some notes in Stanford CS106A(1)
Karel world
1.During make a divider operation
--int x=5; double y = x/2 => y=2
we need sth as a double for the purpose of this operation treat it as though it were a double .
--int x=5; double y = (double)x/2 => y=2.5
OR
--int x=5; double y = x/2.0 => y=2.5
2.Define a const that can't be changed
private static final doule PI=3.14;
final:the value won't change after I give its initial value,
static:there's only one of these for the entire class,
private: it only lives inisde the class.
3.A buggy in boolean
boolean p = (x !=1) || (x!=2)
=>correct is : boolean p = (x !=1) && (x!=2)
4.Scope: lifetime of variable
5.While cast sth that lose information , like from double to a integer , you have to put in the CAST.
ex. double y = 3.5; int x = (int) y;
(if doesn't lose information like int to double , you dont have to cast.)
6.For versus while
For loop used for definite iteration(Generally we know how many times we want to iterate)
While loop used for indefinate iteration(Generally don't know how many times to iterate beforehand.)
Some notes in Stanford CS106A(1)的更多相关文章
- Some notes in Stanford CS106A(4)
1.x++ is a method , the return value is x. (post increment) ++x is also a method , the return value ...
- Some notes in Stanford CS106A(3)
1.If ( str1==str2 ) means if str1 and str2 are refers to the same OBJECT. But when compare string , ...
- Some notes in Stanford CS106A(2)
1.Local variable(local) ex. int i = 0; factorial(i); the "i" outside the method factorial( ...
- Lotus Notes中编程发送邮件(二)
在编程发送各种类似通知的邮件时,时常会需要发件人显示为某个特定的帐户,比如某个部门的名称或者管理员的名字.另一种需求是,用户收到某封邮件后,回复邮件的地址不同于发件人栏显示的地址.而正常情况下,发送邮 ...
- 46. Lotus Notes中编程发送邮件(一)
邮件是Lotus Notes体系的核心和基本功能,以至于Send()是NotesDocument的一个方法,任何一个文档都可以被发送出去,Notes里的一封邮件也只是一个有一些特殊字段的文档.在程序开 ...
- Stanford NLP学习笔记:7. 情感分析(Sentiment)
1. 什么是情感分析(别名:观点提取,主题分析,情感挖掘...) 应用: 1)正面VS负面的影评(影片分类问题) 2)产品/品牌评价: Google产品搜索 3)twitter情感预测股票市场行情/消 ...
- Machine Learning Algorithms Study Notes(4)—无监督学习(unsupervised learning)
1 Unsupervised Learning 1.1 k-means clustering algorithm 1.1.1 算法思想 1.1.2 k-means的不足之处 1 ...
- 84. 从视图索引说Notes数据库(下)
作用和代价上文介绍了关系型数据库里的索引.Notes数据库里的索引隐藏在视图概念里(本文的讨论仅仅针对Notes的视图索引,不包括全文索引.).开发者创建的视图仅仅是存放在数据库里的一条设计文档.数据 ...
- 83. 从视图索引说Notes数据库(上)
索引是数据库系统重要的feature,不管是传统的关系型数据库还是时兴的NoSQL数据库,它攸关查询性能,因而在设计数据库时须要细加考量.然而,Lotus Notes隐藏技术底层.以用户界面为导向.追 ...
随机推荐
- linux添加本地yum源
增加一块硬盘 然后格式化成btrfs格式的文件 mkfs.btrfs /dev/sde 永久挂载 echo "/dev/sde /mnt btrfs defaults 0 0" & ...
- vue中的keep-alive
本文转载于:https://blog.csdn.net/xum222222/article/details/80322532 转载仅供个人日后学习 https://www.cnblogs.com/ji ...
- 织梦默认编辑器换成kindEditor实操教程
织梦默认编辑是CKeditor,要想换成kindEditor编辑器,按如下步骤操作. 先看效果图: 首先下载打包好的 kindEditor_for_dedeCMS.ZIP,下载地址:https://d ...
- GET 和 POST 的区别 以及为什么 GET请求 比 POST请求 更快
引子: 和朋友的聊天中得知他公司后台接口全部都是 POST 请求, 我表示很纳闷为什么全是 POST 请求呢? GET 比 POST 安全,或者说 便于后台方便,后台不用区分包装类 (所以全部用 P ...
- 新建ui文件及相应.h和.cpp文件
1.在Qt Creator中新建一个任意的项目(如untitled): 2.在该项目中添加QT设计师界面类: 3.将新建的3个文件(.ui..h..cpp)拷贝到目标项目文件夹中: 4.分别在目标 ...
- MySQL数据库再回首
前言: 数据库是程序员的数据源泉,加上近期 要开发DB可视化.性能分析的功能 重新回顾一下MySQL知识,以下是笔记: MySQL架构 MySQL基础理论 1.什么是关系型数据库? 关系型数据库,这个 ...
- ArrayList与LinkList
1.ArrayList 1)继承结构 2)ArrayList是数组存储结果,初始容量为0,添加第一个元素后容器为10,后面每次超过容量时,容量递增50%,每次扩容都需要产生新的数组,再把老的数据复制过 ...
- PDF 补丁丁 0.6.0.3355 版发布(修复阅读模式、书签缩放的问题)
PDF补丁丁的新版本修复了染色阅读模式失效.编辑器书签缩放比例调整在某些场合下失败的问题.
- [Oracle][DATAGUARD] 关于确认LOGICAL STANDBY的同期状况的方法
Oracle的DATAGUARD环境,有PHYSICAL STANDBY和LOGICAL STANDBY两种.PHYSICAL STANDBY是传输REDO传到Standby端,然后由Standby端 ...
- OO第四次作业总结
一:测试与正确性论证的效果差异 首先,测试和正确性论证都是对程序的可靠与否,是否有误进行测试,从整体上来看,测试多偏向于实践,而正确性论证则大多偏向于理论. 测试:测试首先是构造一组测试样例,之后将程 ...