⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise9_9.java

📁 java程序设计 机械工业出版社 书籍代码
💻 JAVA
字号:
/**
 * Title:        Chapter 1, "Introduction to Java and JBuilder"
 * Description:  Examples for Chapter 1
 * Copyright:    Copyright (c) 2000
 * Company:      Armstrong Atlantic State University
 * @author Y. Daniel Liang
 * @version 1.0
 */

import java.util.Date;

public class Exercise9_9 {
  static int i;

  public Exercise9_9() {

  }

  public static void main(String[] args) {
    String[] strings = {"CS", "Math", "Biol", "Chem", "Phys", "Buss",
      "Law", "Educ", "Elec Engr", "Mech Engr"};

    Integer[] list = new Integer[10];

    Date[] dates = new Date[10];

    for (int i = 0; i < list.length; i++)
      list[i] = new Integer((int)(Math.random() * 100));

    for (int i = 0; i < list.length; i++)
      dates[i] = new Date();

    System.out.println("Max string is " + max(strings));
    System.out.println("Max integer is " + max(list));
    System.out.println("Max circle is " + max(dates));
  }

  public static Object max(Object[] a) {
    Comparable max = (Comparable)a[0];

    for (int i = 1; i < a.length; i++)
      if (max.compareTo(a[i]) < 0)
        max = (Comparable)a[i];

    return max;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -