Java应用基础微专业-入门篇
第1章--用程序来做计算
1.1 第一个Java程序
Mac version: Preference -> General -> Keys -> Search "Content Assist" for binding to the short-key you want.
1.2 用变量做计算
1.3 表达式(浮点数,优先级和类型转换)
rounding happens to floating number: (e.g. shown below)
System.out.println(1.2-1.1);
output: 0.09999999999999987
第2章--判断
2.1 作比较
comparison between int and double:
int a = 5;
double b = 5.0;
System.out.println(a==b);
output: true
comparison between double and double:
int a = 5;
double b = 5.0;
System.out.println(a==b);
output: true int a = 1.0;
double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1;
System.out.println(b == c);
System.out.println(b+"; "+c);
output: false
output: 1.0; 0.9999999999999999
solution: Math.abs(a-b) < 1e-6;
2.2 判断语句
2.3 多路分支
第3章--循环
3.1 循环(while和do-while循环)
do-while syntax: (cannot image that I even do not remember this)
do {
// body
} while (condition);
3.2 for循环
3.3 循环控制(含复合赋值、逻辑类型)
using break with a label:similar to "goto" in c language
blahblahblah;
LABEL:
for(int i = 0; i < 10; i++) {
blahblahblah
if (...) {
break LABEL; // break the loop labelled "LABEL"
}
}
3.4 循环应用
tricks for integer processing:
得到个位数:%10
去掉最低位:/10
Formatted Print:
System.out.printf("%.2f", x);
第4章--数组
4.1 数组的创建和使用
syntax of defining and creating an array: // fine, haven't write Java for rly a long time
type[] name = new type[size]; // size could be a variable, but it must be provided
e.g: int[] i = new int[array_size];
with initialisation:
type[] name = new type[size];
e.g: int[] i = {1,2,3};
4.2 数组变量和运算
int[] a = new int[size];
initialise array a
int[] b = a; // b just points to the block data which a points to (same block of data)
a == b ? true
but what if a and b points to different blocks of memory?
int[] a = {1,2};
int[] b = {1,2};
a == b ? false
if we wanna compare the content of two arrays: solution--traversing and comparing each pair of element
if we wanna copy an array: solution--traversing and copying each element one by one
syntax for "for-each" loop to traverse an array:
for (type element: array) {}
4.3 二维数组
syntax for creating, initialising, and modifying a two-dimensional array:
int[][] a = new int[size][size];
int[][] a = { {1,2,3,4}, {1,2} };
a[1][2] = 5;
第5章--函数
5.1 函数的定义和调用
函数有多个出口(多个return statements)--> bad design
5.2 函数的参数与本地变量
Java在调用函数时,永远只能传值给函数(?)
life-cycle of a local variable: inside the block
e.g.
{
int i;
}
i = 0; // ERROR
(END)
Java应用基础微专业-入门篇的更多相关文章
- Java应用基础微专业-工程篇
第1章-命令行 1.1 命令行基础 ls -a: list all files (including hidden files) .DS_Store: files detailed informati ...
- Java应用基础微专业-设计篇
第1章--抽象与接口 1.1 抽象 An abstract class can be created without abstract methods, the purpose of doing th ...
- Java应用基础微专业-进阶篇
第1章--使用对象 1.1 字符类型 char c = 65; // char --> int char c = '\u0041'; // \u: unicode + (Hex 41--> ...
- 总结删除文件或文件夹的7种方法-JAVA IO基础总结第4篇
本文是Java IO总结系列篇的第4篇,前篇的访问地址如下: 总结java中创建并写文件的5种方式-JAVA IO基础总结第一篇 总结java从文件中读取数据的6种方法-JAVA IO基础总结第二篇 ...
- 总结java中文件拷贝剪切的5种方式-JAVA IO基础总结第五篇
本文是Java IO总结系列篇的第5篇,前篇的访问地址如下: 总结java中创建并写文件的5种方式-JAVA IO基础总结第一篇 总结java从文件中读取数据的6种方法-JAVA IO基础总结第二篇 ...
- Java中的IO流 - 入门篇
前言 大家好啊,我是汤圆,今天给大家带来的是<Java中的IO流-入门篇>,希望对大家有帮助,谢谢 由于Java的IO类有很多,这就导致我刚开始学的时候,感觉很乱,每次用到都是上网搜,结果 ...
- jQuery学习笔记 - 基础知识扫盲入门篇
jQuery学习笔记 - 基础知识扫盲入门篇 2013-06-16 18:42 by 全新时代, 11 阅读, 0 评论, 收藏, 编辑 1.为什么要使用jQuery? 提供了强大的功能函数解决浏览器 ...
- Java中的集合List - 入门篇
前言 大家好啊,我是汤圆,今天给大家带来的是<Java中的集合List - 入门篇>,希望对大家有帮助,谢谢 简介 说实话,Java中的集合有很多种,但是这里作为入门级别,先简单介绍第一种 ...
- Java中的映射Map - 入门篇
前言 大家好啊,我是汤圆,今天给大家带来的是<Java中的映射Map - 入门篇>,希望对大家有帮助,谢谢 简介 前面介绍了集合List,这里开始简单介绍下映射Map,相关类如下图所示 正 ...
随机推荐
- 自定义属性之LinearLayout ImageView TextView模拟图片文字按钮
一.资源文件: 1.文字选择器: <?xml version="1.0" encoding="utf-8"?> <selector xmlns ...
- Nodejs与mysql连接池的应用(pool)
/* * 连接池 连接和缓存的技术 * */ var mysql = require('mysql'); var pool = mysql.createPool({ connectionLimit:2 ...
- 一点一点看JDK源码(五)java.util.ArrayList 后篇之Spliterator多线程遍历
一点一点看JDK源码(五)java.util.ArrayList 后篇之Spliterator多线程遍历 liuyuhang原创,未经允许禁止转载 本文举例使用的是JDK8的API 目录:一点一点看J ...
- plsql中特殊字符的处理
--去除换行chr(10) update zhzl_address t set t.add_administration_num=replace(t.add_administration_num,ch ...
- QLViewController在iOS7下的自定义
原文来自:QLViewController在iOS7下的自定义 原先的项目使用了quicklook framework,用于在iPhone上浏览各类文件,除了txt文本会有乱码的问题,其他文件的显示都 ...
- IDEA中使用单元测试@Test等,提示没有 Junit.jar包
1.File-->Project Structure-->Modules-->右侧Dependencies-->+号-->JARs or directories... 2 ...
- 大数据学习--day07(冒泡排序、Arrays工具类、方法可变参数)
冒泡排序.Arrays工具类.方法可变参数 冒泡排序之前写过,略 Arrays工具类 二分法查询 public static int binarySearch(int[] a,int key) 头信息 ...
- java synchronized 关键字原理
Synchronized 关键字是解决并发问题常用解决方案,有以下三种使用方式: 同步普通方法,锁的是当前对象.同步静态方法,锁的是当前 Class 对象.同步块,锁的是 {} 中的对象. 实现原理: ...
- python+selenium webdriver.firefox()方式配置浏览器设置
webdriver.firefox() 爬虫需求: (其实是输入参数可获取.zip/pdf 文件,然后点击下载) ——但是firefox浏览器有Bug,点击下载之后会有弹出窗口,需要你点击确定,这怎 ...
- js闭包的理解-目前网上分析的最透彻文章
js的闭包对于大家实际上并不陌生,但是真正敢说自己完全理解的人并不多.笔者在网上看到分析闭包的文章非常多,篇幅用的非常多,但是实际上分析的并不到位,或者根本就是不正确的.我有时候都在想,写这些文章的人 ...