public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
try{
m=Integer.parseInt(jt1.getText());
n=Integer.parseInt(jt2.getText());
}catch(Exception e){
iex=false;
}
//repaint();
writeFile();
setTextToJTextArea();
}private void writeFile() {
// TODO Auto-generated method stub
boolean f;
int i,j;
try{
File file=new File("123.txt");
if(file.exists()){ja.append("文件存在!"/*+lineSeparator*/);}
else{
ja.append("文件不存在!"/*+lineSeparator*/);
file.createNewFile();
ja.append("文件创建成功!"/*+lineSeparator*/);
} BufferedWriter output = null;
if(iex){
for(i=m;i<=n;i++){
f=true;
for(j=2;j<i-1;j++){
if(i%j==0){f=false;break;}
}
if(f){
output = new BufferedWriter(new FileWriter(file));
output.write(""+i+",");
output.newLine();
}
}
output.close();
}
else{
ja.append("输入有误!");
}
}catch(Exception e){e.printStackTrace();}
}
m,n的值在第一个函数中获得,但在第二个函数中,怎么知道m、n的值为多少呢??两个函数不是并列的吗?为什么第二个函数中m、n的值就是第一个函数中m、n的值呢?在下初学,见笑了,请指教 ,非常感谢……
// TODO Auto-generated method stub
try{
m=Integer.parseInt(jt1.getText());
n=Integer.parseInt(jt2.getText());
}catch(Exception e){
iex=false;
}
//repaint();
writeFile();
setTextToJTextArea();
}private void writeFile() {
// TODO Auto-generated method stub
boolean f;
int i,j;
try{
File file=new File("123.txt");
if(file.exists()){ja.append("文件存在!"/*+lineSeparator*/);}
else{
ja.append("文件不存在!"/*+lineSeparator*/);
file.createNewFile();
ja.append("文件创建成功!"/*+lineSeparator*/);
} BufferedWriter output = null;
if(iex){
for(i=m;i<=n;i++){
f=true;
for(j=2;j<i-1;j++){
if(i%j==0){f=false;break;}
}
if(f){
output = new BufferedWriter(new FileWriter(file));
output.write(""+i+",");
output.newLine();
}
}
output.close();
}
else{
ja.append("输入有误!");
}
}catch(Exception e){e.printStackTrace();}
}
m,n的值在第一个函数中获得,但在第二个函数中,怎么知道m、n的值为多少呢??两个函数不是并列的吗?为什么第二个函数中m、n的值就是第一个函数中m、n的值呢?在下初学,见笑了,请指教 ,非常感谢……
解决方案 »
- java 对象
- 纯java: mysql 分布式数据库Proxy解决方案
- 请教一个在线翻译跨页传值的问题!
- 请问JAVA里的DataSource有什么作用?
- 新新手的简单问题~~~~~~~~`看不到RAD窗口摆放界面
- 学习交流。进来留下QQ号
- java如何读取adpcm编码的wav文件??(java好像只支持pcm编码。)
- 不是用odbc,如何连接VFP6.0的DBF文件?
- 氣死咯了,爲什麽用jbuilder6調試一個*.jpr項目,沒有錯誤但是卻不能執行呀?100分~~
- 不合法的类型开始
- (新手提问)欢迎大家讨论下这套笔试题。
- 这段代码错在哪?若要输出的结果是java.awt.color[r=0,g=0,b=0]
全局的话,当然都知道