zoukankan      html  css  js  c++  java
  • 暑假日报-34

    前几天去旅游了,从明天开始会把差的补上

    今天的任务主要是做作业,虽然视频还差几十章没有看,今天完成了以前没有完成的c++作业,其中有一个代码使我疑惑,如下:
    public class 素数
    {
    public static void main(String args[]) throws IOException
    {
    File file=new File("E:\f2.txt");
    BufferedReader a=new BufferedReader(new FileReader(file));
    dog dog1=new dog(14,15);
    String data;
    int i=0;
    ArrayList b=new ArrayList();
    while((data=a.readLine())!=null)
    {
    b.add(data);
    }
    String c=(String)b.get(0);
    String j=(String)b.get(1);
    int m= Integer.parseInt((String)c.subSequence(9,11));
    int l= Integer.parseInt((String)j.subSequence(9,11));
    dog dog2=new dog(l,m);
    System.out.println("dog2的体重为:"+dog2.getweight());
    System.out.print("dog2的年龄为:"+dog2.getage());
    a.close();
    }
    }
    class dog
    {
    private
    int age;
    int weight;
    dog(int a,int b)
    {
    age=a;
    weight=b;
    }
    dog(){};
    public int getage()
    {
    return age;
    }
    public int getweight()
    {
    return weight;
    }
    }
    这道代码最让我疑惑的是为什么用数组来保存文件的数据,反而用集合可以,除此之外我还比较疑惑的是readline的用法,直到网上查了一下才发现readline的真正用法。总的来说,做了这几道题对我的帮助很大,明天我会继续完成剩下的几道文件题,然后在自学剩下的多线程和网络编程。

  • 相关阅读:
    针对图片性能优化的总结
    activityGroup源码分析
    针对BaseAdapter的扩展
    ADB命令介绍
    一个对内存分析的文章。 非常棒。
    hdu 1285 确定比赛名次(很典型的拓扑排序)
    经典排序之归并排序
    hdu 1166 敌兵布阵 (树状数组)
    hdu 3518 Boring counting (后缀数组)
    hdu 3584 Cube(树状数组)
  • 原文地址:https://www.cnblogs.com/L-L-ALICE/p/13472409.html
Copyright © 2011-2022 走看看