Coding
方法
image.pngrefactory
mean change the structure of the code without changing its behavior
一个方法应该是5-10行代码
mortgage重构:
main
readNumber
calculateMortgage
calculateBalance (计算每月结余)
L为本金,p是当前月,n是总月,c是月利率
image.png
printMortgage
笔记:
多个class公用的变量,要在class外声明。在main类中声明也不行??
而且要写成 final static ...
image.png
Extract Method
image.png image.pngDebugs
Errors
- Compile-time Error:语法错误,还未运行就会报错
变量未指定类型
分号结尾
- Run-time Error:需要Debugger
debugger
插入break point,左侧为红色
run:debug main
蓝色 step over,step into
绿色 rerun
image.png
打包jar
File- Project Structure- Artifacts
创建Artifacts- JAR-From modules with dependencies -选择main class
Build -build artifacts
在out-artifacts-moshjava.java右键 open in terminal
java -jar MoshJava.jar
网友评论