zoukankan      html  css  js  c++  java
  • Java初体验

    1. Write your Java source code program in a text editor and save it with a .java extension. Make sure that your text editor saves the file in plain ASCII format, and make sure that it supports long file names. You can't save a Java program as a .jav file -- the extension has to be .java.


    2. Compile your program from a command-line prompt, using the javac compiler that comes with the SDK. For example, for a source code file named Sample.java, you would type javac Sample.java. If all goes well, a Java class file will be produced. In our example, this file would be
    called Sample.class. Remember to always specify the .java extension when compiling a Java program.

    3. Run your program from a command-line prompt, using the java interpreter that comes with the SDK. For example, to run the Sample program from the previous step, you would type java Sample. To specify command-line arguments to a Java program, simply type them
    after the program name, separated by spaces. Remember to never specify the .class extension when running a Java program.

    4. Errors can occur when compiling or running a Java program. As you know, run-time errors are more difficult to debug than compile-time errors. When you are new to a language, however, compile-time error messages can seem very cryptic. Correcting compile-time errors can be very instructive, but if you can't get any of the examples in this tutorial to work。

    public class Factorial {
    public static void main(String[] args) {
    if(args.length != 0) {
    int num = Integer.parseInt(args[0]);
    System.out.println(factorial(num));
    }
    }
    private static int factorial(int fact) {
    int result = fact;
    if (fact == 0)
    return result;
    else {
    while (fact != 1)
    result *= --fact;
    }
    return result;
    }
    }
  • 相关阅读:
    全面提价2499元起小米6发布:四曲陶瓷机身+骁龙835+变焦双摄(小米在设计上也多次获得红点最佳、iF金奖等72项工业设计大奖)
    VCL的通用属性,方法和事件 good
    抗日名将粟裕
    部署 Redis 群集
    Xamarin
    NET Core控制反转(IoC)
    C#开发Linux守护进程
    数据一致性(consistency)、服务可用性(availability)、分区容错性(partition-tolerance)
    ssm框架
    javascript面向对象之闭包
  • 原文地址:https://www.cnblogs.com/allenblogs/p/2233268.html
Copyright © 2011-2022 走看看