是五月呀!


  • 首页

  • 分类

  • 归档

  • 标签

  • 关于
是五月呀!

java包装类

发表于 2018-09-27 | 分类于 java | 字数统计: 1,017(字) | 阅读时长: 4(分)

1. 自动装箱与自动拆箱

那我们来分析Integer i = 5;的过程;
在jdk1.5以前,这样的代码是错误的,必须要通过Integer i = new Integer(5);这样的语句实现;
而在jdk1.5以后,Java提供了自动装箱的功能,只需Integer i = 5;这样的语句就能实现基本数据类型传给其包装类,JVM为我们执行了Integer i = Integer.valueOf(5);。

相对应的,把基本数据从对应包装类中取出的过程就是拆箱,如

1
2
Integer i = 5;
int j = i; // 这样的过程就是自动拆箱

源码方面,装箱过程是通过调用包装器的valueOf方法实现的,而拆箱过程是通过调用包装器的xxxValue方法实现的。(xxx代表对应的基本数据类型)

阅读全文 »
是五月呀!

云音乐抓取

发表于 2018-09-21 | 分类于 java , spring | 字数统计: 4,001(字) | 阅读时长: 19(分)

1. 初衷

作为云音乐的死忠用户,在大量版权丢失的情况下,依然坚守阵地,除了对UI的喜欢,还有就是歌曲下面精彩的评论信息了。
翻过很多热评后,就想把这些数据抓取下来。有了数据,就可以做数据分析。

阅读全文 »
是五月呀!

BigDecimal精度

发表于 2018-09-12 | 分类于 java | 字数统计: 1,090(字) | 阅读时长: 6(分)

1. 构造函数的坑

1
2
3
4
5
6
7
8
9
public class BigDecimalTest {
public static void main(String[] args){
double number = 6302079.05;
BigDecimal bigDecimalFromDouble = new BigDecimal(number);
LOGGER.info("bigDecimalFromDouble={}", bigDecimalFromDouble);
BigDecimal bigDecimalFromString = new BigDecimal(String.valueOf(number)) ;
LOGGER.info("bigDecimalFromString={}", bigDecimalFromString);
}
}

输出结果:

1
2
bigDecimalFromDouble=6302079.049999999813735485076904296875
bigDecimalFromString=6302079.05

可以看到,直接使用double作为参数构造BigDecimal时,会丢失精度。
所以推荐的是先将double转化为字符串,然后赋值给构造函数。

阅读全文 »
是五月呀!

git从某一次提交上创建分支

发表于 2018-09-11 | 分类于 git | 字数统计: 224(字) | 阅读时长: 1(分)

从某一次提交上创建分支使用如下命令:

1
git branch <branch name> <start point>

平时我们是在当前分支的最新代码上迁出新分支,那么可以忽略后面的<start point>。

1
git branch new_branch

假如我们想在某一次提交的基础上迁出新分支,那么就需要使用<start point>了,写上该提交的SHA值。

阅读全文 »
是五月呀!

git远程仓库管理

发表于 2018-09-11 | 分类于 git | 字数统计: 58(字) | 阅读时长: 1(分)

查看:

1
git remote -v

添加:

1
git remote add origin git@github.com:michaelliao/learngit.git

修改:

1
git remote set-url origin git@github.com:michaelliao/learngit.git

或者:

1
2
git remote rm origin
git remote add origin git@...git

强制push覆盖远程:

1
git push -f <remote> <branch>

是五月呀!

git删除操作

发表于 2018-09-11 | 分类于 git | 字数统计: 228(字) | 阅读时长: 1(分)

1.同时从本地与版本库中删除

1
git rm [-r] [-n] <file>

-r参数递归移除目录。
-n加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览,所以一般用这个参数先看看要删除哪些文件,防止误删,确认之后,就去掉此参数,真正的删除文件。

2.仅从版本库中删除

我们想把文件从 Git 仓库中删除(亦即从暂存区域移除),但仍然希 望保留在当前工作目录中。换句话说,仅是从跟踪清单中删除。
比如一些大型日志文件或者一堆.a 编译文件,不小心纳入仓库后,要移除跟踪但不删除文件,以便稍后在 .gitignore 文件中补上,用 –cached 选项即可。

1
git rm [-r] [-n] --cached <file>
是五月呀!

git分支操作

发表于 2018-09-11 | 分类于 git | 字数统计: 29(字) | 阅读时长: 1(分)

1.checkout远程分支到本地

1
git checkout -b <local_branch_name> origin/<remote_branch_name>

2.提交到远程分支

1
git push origin <remote_branch_name>
是五月呀!

git回滚

发表于 2018-09-11 | 分类于 git | 字数统计: 937(字) | 阅读时长: 4(分)

1.git revert

1
git revert <commit>

命令的含义是:

Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them. This requires your working tree to be clean (no modifications from the HEAD commit).

Note: git revert is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one).
If you want to throw away all uncommitted changes in your working directory, you should see git-reset, particularly the --hard option.
If you want to extract specific files as they were in another commit, you should see git-checkout, specifically the git checkout <commit> -- <filename> syntax.
Take care with these alternatives as both will discard uncommitted changes in your working directory.

阅读全文 »
是五月呀!

git配置信息管理

发表于 2018-09-11 | 分类于 git | 字数统计: 145(字) | 阅读时长: 1(分)

查看git全局设置信息:

1
git config -l

设置配置信息:

1
git config --global user.name="Your Name"

这里的--global参数表示示你这台机器上所有的Git仓库都会使用用这个配置,当然也可以对某个仓库指定不同的用用户名和Email地址。

配置别名:

1
2
3
4
5
6
7
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.unstage 'reset HEAD'
git config --global alias.last 'log -1'
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

是五月呀!

git撤销修改

发表于 2018-09-11 | 分类于 git | 字数统计: 2,197(字) | 阅读时长: 10(分)

基本的命令含义参考:代码回滚:Reset、Checkout、Revert的选择

初始化一个空的测试目录:

1
2
3
4
 ~/git/ git init
Initialized empty Git repository in /Users/git/.git/
 ~/git/ [master] ls
 ~/git/ [master]

阅读全文 »
1…4567
五月y

五月y

Hello 五月y!

67 日志
24 分类
20 标签
RSS
GitHub weibo zhihu
© 2017 - 2018 五月y
由 Hexo 强力驱动
主题 - NexT.Mist