zoukankan      html  css  js  c++  java
  • java第五天之---方法与数组

    案例一:从键盘输入两个数据,比较大小

    import java.util.Scanner;
    class FunctionTest {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("input a number:");
        int a = sc.nextInt();

        System.out.println("input another nuber:");
        int b = sc.nextInt();

        int result = Getmax(a,b);
        System.out.println("maxvalue:"+result);
      }
      public static int Getmax(int a,int b) {
        if(a > b) {
          return a;
        }else {
          return b;
        }
      }
    }

    执行结果:

    D:>java FunctionTest
    input a number:
    45
    input another nuber:
    88
    maxvalue:88

    案例二:比较键盘输入的两个数值是否相等

    输出结果:

    D:java_code>java FunctionTest01
    input a number:
    88
    input another nuber:
    88
    True or False: true

     #####################################################

    输出结果:

    D:java_code>java FunctionTest02
    input a number:
    8
    input another nuber:
    8
    ********
    ********
    ********
    ********
    ********
    ********
    ********
    ********

    ###############数组##########################

    ############数组遍历##############

    #############获取最大与最小值###############

    ################数组元素倒叙######################

     

    另外一种方法:

    ###########数组查表法######################

    ###########查找数组对应的索引##############

  • 相关阅读:
    转载viewstate(一) 太经典的东西 不得不转载保存下来
    Asp.Net中HttpModule的研究(转)
    linux学习笔记(9)
    老手经验谈:Linux驱动程序开发学习步骤(转)
    浅谈C中的malloc和free(1)
    ASP.NET的HttpModule和HttpHandler(转)
    C语言学习笔记(1)
    xcode 4 code sense
    不是bug 是教训
    win7 管理员 开关命令
  • 原文地址:https://www.cnblogs.com/shanhua-fu/p/7079841.html
Copyright © 2011-2022 走看看