【AG真人系统源码下载】【模拟器怎么找到网页源码】【微信小程序抽奖开源码】java源码分享比较经典的源码

2024-11-25 02:34:55 来源:office源码大概多少行 分类:热点

1.java源代码 求大神 明天就要上机

java源码分享比较经典的源码

java源代码 求大神 明天就要上机

       package com.uisftec;

       import java.io.Serializable;

       public class TestScores implements Serializable {

        private double[] testScores;

        public TestScores(double[] testScores) {

        this.testScores = testScores;

        }

        public double getAverageScore() {

        double sum = 0.0d;

        for (int i = 0; i < testScores.length; i++) {

        sum += testScores[i];

        }

        return sum / testScores.length;

        }

       }

       package com.uisftec;

       public class InvalidTestScore {

        public InvalidTestScore(double[] testScores) {

        if (testScores == null) {

        throw new IllegalArgumentException("数组为空");

        }

        for (int i = 0; i < testScores.length; i++) {

        if (testScores[i] < 0 || testScores[i] > ) {

        throw new IllegalArgumentException("数组中包含的test Score不在0~这个范围内");

        }

        }

        }

       }

       package com.uisftec;

       import java.io.DataOutputStream;

       import java.io.File;

       import java.io.FileInputStream;

       import java.io.FileNotFoundException;

       import java.io.FileOutputStream;

       import java.io.IOException;

       import java.io.ObjectInputStream;

       import java.io.ObjectOutput;

       import java.io.ObjectOutputStream;

       public class TestScoresSerialize {

        public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {

        // 创建5个对象

        TestScores testScores1 = new TestScores(new double[] { 1.0, 2.0 });

        TestScores testScores2 = new TestScores(new double[] { 5.0, 2.0 });

        TestScores testScores3 = new TestScores(new double[] { .0, .0 });

        TestScores testScores4 = new TestScores(new double[] { .0, .0 });

        TestScores testScores5 = new TestScores(new double[] { .0, .0 });

        // 创建数组

        TestScores[] testScores = new TestScores[] { testScores1, testScores2, testScores3, testScores4, testScores5 };

        // 写入到D盘testScores.dat

        ObjectOutput out = new ObjectOutputStream(new FileOutputStream("d:\\testscores.dat"));

        for (TestScores testScores6 : testScores) {

        out.writeObject(testScores6);

        }

        // D盘STOUT

        File file = new File("D:\\STDOUT");

        // 创建输出留

        DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(file));

        // 创建读取d盘序列化对象

        ObjectInputStream in = new ObjectInputStream(new FileInputStream("d:\\testscores.dat"));

        // 打印平均分并写入到D盘STDOUT

        TestScores testScores8 = (TestScores) in.readObject();

        System.out.println(testScores8.getAverageScore());

        outputStream.writeDouble(testScores8.getAverageScore());

        TestScores testScores9 = (TestScores) in.readObject();

        outputStream.writeDouble(testScores9.getAverageScore());

        System.out.println(testScores9.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        // 关闭流

        out.close();

        in.close();

        outputStream.close();

        }

       }

更多资讯请点击:热点

热门资讯

全网直播源码

2024-11-25 02:332760人浏览

拼拼源码

2024-11-25 02:281956人浏览

linease 源码

2024-11-25 02:252188人浏览

2.43源码

2024-11-25 01:491337人浏览

APP源码流出

2024-11-25 01:341033人浏览

源码 开运

2024-11-25 01:20741人浏览

推荐资讯

apache ignite 源码

1.如何使用apache ignite如何使用apache ignite Apache Ignite内存数据组织是高性能的、集成化的以及分布式的内存平台,他可以实时地在大数据集中执行事务和计算,和

源码看书

1.Դ?뿴??2.Python 从入门到精通推荐看哪些书籍呢?3.有一定编程基础想学C++看什么书好了?4.C# ,线程和DLL,相关书籍Դ?뿴?? 先看书,宏

drf源码

1.django后端用什么写?2.django是前端还是后端3.django有什么版本(django现在版本)4.深入理解 Hadoop 七)YARN资源管理和调度详解5.