Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c3adf5

Browse filesBrowse files
committed
Merge pull request giantray#52 from Yixiaohan/patch-3
代码排版、修改错别字
2 parents 3a6e5f3 + 4164f04 commit 6c3adf5
Copy full SHA for 6c3adf5

File tree

Expand file treeCollapse file tree

1 file changed

+3
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-2
lines changed

‎contents/avoiding-null-statements-in-java.md

Copy file name to clipboardExpand all lines: contents/avoiding-null-statements-in-java.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ if (parser == null) {
7575
}
7676
Action action = parser.findAction(someInput);
7777
if (action == null) {
78-
// do nothing} else {
78+
// do nothing}
79+
else {
7980
action.doSomething();}
8081
```
8182

@@ -95,7 +96,7 @@ ParserFactory.getParser().findAction(someInput).doSomething();
9596
而不是
9697
`foo.equals("bar") `
9798
- Java8或者guava lib中,提供了Optional类,这是一个元素容器,通过它来封装对象,可以减少判空。不过代码量还是不少。不爽。
98-
- 如果你想返回null,请挺下来想一想,这个地方是否更应该抛出一个异常
99+
- 如果你想返回null请停下来想一想,这个地方是否更应该抛出一个异常
99100

100101
stackoverflow链接:
101102
http://stackoverflow.com/questions/271526/avoiding-null-statements-in-java?page=2&tab=votes#tab-top

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.