siesteven

其实标题就是骗人的。我其实是在看哔哩哔哩上  马士兵  的java ee 的初级教程视频。

今天主要的收获有 个

1、局部变量  new的对象的存储区。

2、程序运行时,对象生存周期的变化。

3、第一章的基础知识点。如下所示

4、内存解析。比看书本清晰明了多了。啃完  java编程思想,还是迷迷糊糊的。很无奈!

5、偶遇求阶乘的一道题。觉得那个写法很好。充分利用了运算过程中的值。确实省去了很大开销。代码如下(今天洗衣服,编码时间短了,没写注释,没格式化,没标准化。。。欠着了。。。):

 1 package chuanzhiboke;
 2 
 3 public class Day2 {
 4     private static Day1 day1=new Day1();
 5 public static void main(String args[]){
 6     calculateFactor();
 7 }
 8 
 9 private static void calculateFactor(){
10     Integer startNum=1;
11     Integer endNum=10;
12     Integer oneToTen= calculateFactorialSum( startNum, endNum);
13     Integer ten= calculateFactorialOneNumber(endNum);
14 
15     Integer nine=  calculateFactorialSum(1,9);
16     day1.showMsg(oneToTen.toString());
17     day1.showMsg(ten.toString());
18     day1.showMsg( nine.toString());
19     day1.showMsg(oneToTen + " - "+ten+" = "+( oneToTen-ten));
20 }
21 
22 private static Integer calculateFactorialSum(Integer startNum,Integer endNum){
23     Integer result=0;
24     Integer tempNum=1;
25     for(int i=startNum;i<=endNum;i++){
26         tempNum*=i;
27         result+=tempNum;
28     }
29     day1.showMsg(result.toString());
30     return result;
31 }
32 
33 private static Integer calculateFactorialOneNumber(Integer seed){
34     Integer result=1;
35     for(int i=1;i<=seed;i++){
36         day1.showMsg(result+"*"+i);
37         result*=i;
38     }
39     day1.showMsg(result.toString());
40     return result;
41 }
42 }

 

分类:

技术点:

相关文章:

  • 2021-12-04
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2021-09-28
  • 2022-02-10
  • 2021-07-03
  • 2021-11-22
  • 2021-10-16
相关资源
相似解决方案