此源代码在别的人机子运行通过.但在我的机子上用JAVAC编绎时却有100个错误.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest
{public static void main(String []args)
{WelcomeFrame frame = new WelcomeFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//setDefaultCloseOperation();
frame.show();
}
}
class WelcomeFrame extends JFrame
{ public WelcomeFrame()
{ setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
WelcomePanel panel = new WelcomePanel();
Container contentPane =getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}
class WelcomePanel extends Panel
{ public WelcomePanel()
{ Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("Welcome");
add(prompt);
add(input);
add(output);
add(btnn);
btnn.addActionListener(new
ActionListener()
{ public void actionPerformed(ActionEvent event)
{ String s = input.getText();
output.setText("Hello"+s+",欢迎您参加Java考试!");
}
});
}
}
我是在SUN的官网上下载的SDK.PATH和CLASSPATH都设置了.要说JAVA没装好吧,但是一些小程序又编译解释通过了.我用的是WINDOWSXP.我现在真的是不知道问题出在哪里,急死了.请有经验的高手帮我分析一下到底是哪里出了问题..发自内心的感谢.还希望高手把QQ跟我说一下.我的QQ是119082658.还有下面这个程序也是100个错误.
public class OperatorsAndExpressions {
void singleArithmaticOperator() {
float i = 2.0f, j = 10.0f;
int m = 20, n = 10;
System.out.println((++i) * (j--));
System.out.println("i=" + i + ",j=" + j);
System.out.println((i++) * (j--));
System.out.println("i=" + i + ",j=" + j);
System.out.println((--m) * (n++));
System.out.println("m=" + m + ",n=" + n);
System.out.println((m--) * (n++));
System.out.println("m=" + m + ",n=" + n);
} public static void main(String arga[]) {
OperatorsAndExpressions OperAndExp = new OperatorsAndExpressions();
OperAndExp.singleArithmaticOperator();
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WelcomeTest
{public static void main(String []args)
{WelcomeFrame frame = new WelcomeFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//setDefaultCloseOperation();
frame.show();
}
}
class WelcomeFrame extends JFrame
{ public WelcomeFrame()
{ setTitle("Welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
WelcomePanel panel = new WelcomePanel();
Container contentPane =getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}
class WelcomePanel extends Panel
{ public WelcomePanel()
{ Label prompt = new Label("请输入您的名字:");
final TextField input = new TextField(10);
final TextField output = new TextField(25);
Button btnn = new Button("Welcome");
add(prompt);
add(input);
add(output);
add(btnn);
btnn.addActionListener(new
ActionListener()
{ public void actionPerformed(ActionEvent event)
{ String s = input.getText();
output.setText("Hello"+s+",欢迎您参加Java考试!");
}
});
}
}
我是在SUN的官网上下载的SDK.PATH和CLASSPATH都设置了.要说JAVA没装好吧,但是一些小程序又编译解释通过了.我用的是WINDOWSXP.我现在真的是不知道问题出在哪里,急死了.请有经验的高手帮我分析一下到底是哪里出了问题..发自内心的感谢.还希望高手把QQ跟我说一下.我的QQ是119082658.还有下面这个程序也是100个错误.
public class OperatorsAndExpressions {
void singleArithmaticOperator() {
float i = 2.0f, j = 10.0f;
int m = 20, n = 10;
System.out.println((++i) * (j--));
System.out.println("i=" + i + ",j=" + j);
System.out.println((i++) * (j--));
System.out.println("i=" + i + ",j=" + j);
System.out.println((--m) * (n++));
System.out.println("m=" + m + ",n=" + n);
System.out.println((m--) * (n++));
System.out.println("m=" + m + ",n=" + n);
} public static void main(String arga[]) {
OperatorsAndExpressions OperAndExp = new OperatorsAndExpressions();
OperAndExp.singleArithmaticOperator();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货