1、文件读取并打印
import java.io.*;
public class readandprint{ //*********Found********public static void main(String args[]) throws Exception{ long filePoint = 0 ;String s;RandomAccessFile file = new RandomAccessFile("D:\\javaceshu\\readandprint.java","r");long fileLength = file.length();while (filePoint<fileLength){ //*********Found********s = file.readLine();System.out.println(s); filePoint = file.getFilePointer(); }file.close(); } }2、图形程序显示乘法
import javax.swing.JOptionPane;
public class Java_1 { public static void main( String args[] ) { int x, y, result;String xVal, yVal;xVal = JOptionPane.showInputDialog( "输入第1个整数:" );yVal = JOptionPane.showInputDialog( "输入第2个整数:" );//*********Found********x = Integer.parseInt(xVal);y = Integer.parseInt( yVal );result = x * y;//*********Found********JOptionPane.showMessageDialog( null, "两个数的积: " + result );System.exit( 0 );}}3、从命令行参数输入 java_24_3 7 (先编译完后)会显示7的阶乘是5040
public class _24_3{
public static void main(String[] args){ String num;if(args.length > 0)//*********Found********num =args[0];elsenum = "5";//*********Found********int input = Integer.parseInt(num);int result = Java_3(input);System.out.println(input+ " 的阶乘是 "+ result);}public static int Java_3(int x){ if( x < 0 )return 0;int fact = 1;while(x > 1){ //*********Found********fact = fact * x;x = x-1;}return fact;}}