zoukankan      html  css  js  c++  java
  • 动手动脑2

    package we;


    public class MethodOverload {

    public static void main(String[] args) {
    System.out.println("The square of integer 7 is " + square(7));
    System.out.println("\nThe square of double 7.5 is " + square(7.5));
    }

    public static int square(int x) {
    return x * x;
    }

    public static double square(double y) {
    return y * y;
    }
    }

    发生了重载,

    满足以下条件的两个或多个方法构成“重载”关系: (1)方法名相同; (2)参数类型不同,参数个数不同,或者是参数类型的顺序不同。

    动手动脑: 编写一个方法,使用以上算法生成指定数目(比如1000个)的随机整数。

    package we;

    import java.util.Random;
    import java.util.Scanner;

    public class we
    {
    public static void main(String[] args)
    {

    Random x = new Random(System.currentTimeMillis());
    System.out.println("随机数数量");
    int y;
    Scanner in = new Scanner(System.in);
    y= in.nextInt();
    for(int i=0;i<y;i++)
    System.out.println( x.nextInt());

    }
    }

    文件导入

     InputStream fis = new FileInputStream("d:" + File.separator + "test.txt");
    byte[] buf = new byte[1024]; int len;
     String myStr = ""; while((len = fis.read(buf)) != -1)


     
     
     
  • 相关阅读:
    判断是否为蜘蛛抓取
    js Date
    JavaScript_Date对象说明
    php过滤字符串函数
    js 高考倒计时
    php 修改数据编码
    php 二维数组冒泡排序
    PSD网页切图制作HTML全过程教程
    产品经理职责
    互联网产品设计
  • 原文地址:https://www.cnblogs.com/yyl141/p/11599829.html
Copyright © 2011-2022 走看看