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;
    }
    }
  • 相关阅读:
    用动画切换按钮的状态
    用UICollectionView实现无限轮播图
    水平方向瀑布流
    UICollectionViewFlowLayout使用示例
    旋转木马效果
    Greenplum集群或者Postgresql出现死锁肿么办?
    Lucene的全文检索学习
    Jms规范学习
    Nginx的相关问题
    keepalived+Nginx实现主备保障Nginx的高可用。
  • 原文地址:https://www.cnblogs.com/allenblogs/p/2233268.html
Copyright © 2011-2022 走看看