zoukankan      html  css  js  c++  java
  • 从零自学Java-2.初步理解Java程序使如何工作的

    1.学习Java应用程序是如何工作的

    2.构成一个应用程序

    3.向应用程序传递参数

    4.学习Java程序是如何组织的

    5.在应用程序中创建一个对象

    程序Root:输出225的正平方根

     1 package com.jsample;//应用程序位于jsample包中
     2 
     3 public class Root {
     4     public static void main(String[] args){
     5         int number=225;//变量number存储255
     6         System.out.println("The square root of "//显示该整数及其平方根
     7                 +number
     8                 +" is "
     9                 +Math.sqrt(number)//显示平方根
    10         );
    11     }
    12 }
    View Code

    程序AnotherRoot:输出625的正平方根

     1 package com.jsample;
     2 
     3 public class AnotherRoot {
     4     public static void main(String[] args)
     5     {
     6         int number = 625;
     7         System.out.println("The square root of "//显示该整数及其平方根
     8                 +number
     9                 +" is "
    10                 +Math.sqrt(number)
    11         );//显示平方根
    12     }
    13 }
    View Code

    程序blank filler:传递参数,填空

     1 package com.jsample;
     2 
     3 public class AnotherRoot {
     4     public static void main(String[] args)
     5     {
     6         int number = 625;
     7         System.out.println("The square root of "//显示该整数及其平方根
     8                 +number
     9                 +" is "
    10                 +Math.sqrt(number)
    11         );//显示平方根
    12     }
    13 }
    View Code

    程序NewRoot:传递参数,转化为double型,并输出其正平方根

     1 package com.jsample;
     2 
     3 public class NewRoot {
     4     public static void main(String[] args)
     5     {
     6         System.out.println("The square root of "//显示该整数及其平方根
     7                 +args[0]
     8                 +" is "
     9                 +Math.sqrt(Double.parseDouble(args[0]))//显示平方根,然而Java在运行时将所有参数
    10         );                                             //存储为字符串,需要转换
    11     }
    12 }
    View Code
  • 相关阅读:
    lambda 和 iterable
    使用Jenkins部署Python项目
    python下selenium自动化测试自我实践
    【其它】数学学科编码
    【其它】音阶中的数学
    【数理统计基础】 06
    【数理统计基础】 05
    【数理统计基础】 04
    【数理统计基础】 03
    【数理统计基础】 02
  • 原文地址:https://www.cnblogs.com/redlogic/p/8563622.html
Copyright © 2011-2022 走看看