请大神解答
package com.hbzf.tesst;import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class MyJFrame {
publicMyJFrame(int a,int b)
{
cheng( a, b);
jia(a,b);
jian(a,b);
chu(a,b);
}
public void cheng(int a,int b)
{
System.out.println("这两个数相乘 = "+(a*b));
}
public void jia(int a,int b)
{
System.out.println("这两个数相加 = "+(a+b));
}
public void jian(int a,int b)
{
System.out.println("这两个数相减 = "+(a-b));
}
public void chu(int a,int b)
{
if(b!=0)
{
System.out.println("这两个数相除 = "+(a/b));
}else
{
System.out.println("Error");
}
}
MyJFrame jg= new MyJFrame(10,12);
public static void main(String[] args) {
JFrame jf = new JFrame();
jf.setSize(300,200);
jf.setLocation(300, 300);
jf.setVisible(true);
jf.setDefaultCloseOperation(0);
jf.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
jf.add(jg);
}
}
真简洁,解答什么?
页:
[1]