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;
    }
    }
  • 相关阅读:
    骚猪队的模板
    cs231n 作业2 心路历程
    cs231n 作业1 心路历程
    视觉语言导航综述Visual Language Navigation
    论文阅读DSAE,不知道VAE能不能玩的下去
    icpc 2019 word final A题 思路
    VAE 变分自动编码器入门
    luogu4827 梦美的线段树
    EOJ Monthly 2019.2 存代码
    国王游戏,高精度完全模板
  • 原文地址:https://www.cnblogs.com/allenblogs/p/2233268.html
Copyright © 2011-2022 走看看