java input and output, writing specifications, operation principle, cross-platform principle (review)

Probably a java program execution:

Cross-platform java virtual machine principle: Whatever the system, java source code program through javac compiler into binary .class files,

.class file executed at runtime interpreted as corresponding platform in the jvm (virtual machine) machine code.

 

9 * 9 with reverse multiplication table illustrates the output console messages, interviews encountered such a face questions:

The same as (1) the class name and the file name, the first letter of your capital; (2) main program entry (only one entrance);

(3) System.out.println () This is the output of information from the console line feed

{class Chengfa public
  public static void main (String [] args) {
    //. 9 * reverse the multiplication table. 9, a for loop is used
    for (int I =. 9; I> 0; i--) {
      for (int J I =; J> 0; J,) {
      of System.out.print (I + "*" + J + "=" + I * J);

      System.out.print(" ");
      }
         System.out.println();
    }  
  }
}

Example n * n input information and outputs the multiplication table descending console message:

import java.util.Scanner;

{class Chengfa public
  public static void main (String [] args) {
    // Create Object Scanner (Scanner class can obtain user input)
    Scanner Scanner new new INPUT = (the System.in);
    System.out.println ( "Please enter multiplier : ");

    // int define a variable, the console assigned with
    int input.nextInt A = ();
    // * n-n-descending multiplication table
    for (int I = A; I> 0; i--) {
      for (int I = J ; J> 0; J,) {
        of System.out.print (I + "*" + J + "=" + I * J);
       }
          System.out.println ();
      }

    }
}

 

Guess you like

Origin www.cnblogs.com/FanKL/p/11142104.html