此代碼包含附加到字符串的自動遞增數字...我希望它一樣..但增量應該發生在每次調用程序時固定字符串的自動增量值對於每次調用程序
public class Class //main method contain method calls
{
private static int count = 0;
private int jobID;
private static String name;
private boolean isFilled;
public Class1(String title)
{
name = title;
isFilled = true;
setJobID(++count);
}
public int getJobID()
{
return jobID;
}
public void setJobID(int jobID)
{
this.jobID = jobID;
}
public static void main(String[] args) // code for auto generation
{
for (int i = 0; i < 3; i++)
{
Class1 tst = new Class1("");
System.out.print(name);
System.out.println(tst.getJobID());
}
}
}
不要任何人有一個包含有一個ID號碼(例如:XXX-0000)固定字符串的程序和場數「0000」值應遞增每次調用程序
輸出.. :xxx-0001 xxx-02 xxx-03(XXX是字符串) –
您必須保留上次使用的號碼 – Jens
您必須將最後生成的id保存在某處(文件,數據庫,Intranet/Internet上的服務器,. ..)取決於你的用例。 –