两个for的:
public final class two_for {
/**
* @param args
*/
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + "*" + i + "=" + i * j + "\t@");
}
System.out.println();
}
}
}
............................
一个for的:
import java.awt.Font;
import java.awt.TextArea;
import javax.swing.JFrame;
public final class one_for extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* @param args
*/
TextArea textArea = new TextArea();
one_for() {
super("0.0");
this.add(textArea);
nine();
// textArea.setEditable(false);// 设置不可编辑
textArea.setEnabled(false);// 设置的是不可用
textArea.setFont(new Font("", Font.LAYOUT_RIGHT_TO_LEFT, 15));
this.setResizable(false);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(920, 210);
}
public void nine() {
for (int i = 1, j = 1; i <= 9; j++) {
textArea.append(j + "*" + i + "=" + j * i + " \t&");
if (i == j) {
i++;
j = 0;
textArea.append("\n");
}
}
}
public static void main(String[] args) {
new one_for();
}
}
参考资料:0.0