当前位置: 技术问答>java相关
请问这段程序应该怎么修改阿,为什么老是编译不过去?
来源: 互联网 发布时间:2015-07-15
本文导语: import java.util.*; public class test { String APPCOD="2002123456"; int app1=Integer.parseInt(APPCOD.substring(4)); int app2=Integer.parseInt(APPCOD.substring(0,3)); ...
import java.util.*;
public class test {
String APPCOD="2002123456";
int app1=Integer.parseInt(APPCOD.substring(4));
int app2=Integer.parseInt(APPCOD.substring(0,3));
Calendar cal = Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
if(app2=year){
app1=app1+1;
int cod=year*1000000+app1;
APPCOD=cod;
}
else{
APPCOD=year*1000000+1;
}
System.out.println(APPCOD);
}
public class test {
String APPCOD="2002123456";
int app1=Integer.parseInt(APPCOD.substring(4));
int app2=Integer.parseInt(APPCOD.substring(0,3));
Calendar cal = Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
if(app2=year){
app1=app1+1;
int cod=year*1000000+app1;
APPCOD=cod;
}
else{
APPCOD=year*1000000+1;
}
System.out.println(APPCOD);
}
|
这样当然编译不过去了
应该把你的执行代码写到一个方法里面
import java.util.*;
public class test {
String APPCOD="2002123456";
public void main(){
int app1=Integer.parseInt(APPCOD.substring(4));
int app2=Integer.parseInt(APPCOD.substring(0,3));
Calendar cal = Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
if(app2=year){
app1=app1+1;
int cod=year*1000000+app1;
APPCOD=cod;
}
else{
APPCOD=year*1000000+1;
}
System.out.println(APPCOD);
}
}
这样应该就行了
应该把你的执行代码写到一个方法里面
import java.util.*;
public class test {
String APPCOD="2002123456";
public void main(){
int app1=Integer.parseInt(APPCOD.substring(4));
int app2=Integer.parseInt(APPCOD.substring(0,3));
Calendar cal = Calendar.getInstance();
int year=cal.get(Calendar.YEAR);
if(app2=year){
app1=app1+1;
int cod=year*1000000+app1;
APPCOD=cod;
}
else{
APPCOD=year*1000000+1;
}
System.out.println(APPCOD);
}
}
这样应该就行了