当前位置: 技术问答>java相关
SOS~~~~
来源: 互联网 发布时间:2015-03-23
本文导语: //I public class ApplicantCollection { String applicantName; String applicantAddress; String applicantPosition; public void displayDetails(){ System.out.println(applicantName); System.out.println(applicantAddress); System.out.println(applicantPosition);} Applicant appO...
//I
public class ApplicantCollection
{
String applicantName;
String applicantAddress;
String applicantPosition;
public void displayDetails(){
System.out.println(applicantName);
System.out.println(applicantAddress);
System.out.println(applicantPosition);}
Applicant appObject[];
public ApplicantCollection(){
appObject=new Applicant[3];
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr]=new Applicant();
}
appObject[0].applicantName="汤姆";
appObject[0].applicantAddress="北京";
appObject[0].applicantPosition="manger";
appObject[1].applicantName="莹";
appObject[1].applicantAddress="济南";
appObject[1].applicantPosition="高级软件工程师";
appObject[2].applicantName="风";
appObject[2].applicantAddress="大连";
appObject[2].applicantPosition="软件工程师";}
public void displayCollection(){
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr].displayDetails();}}
public static void main(String args[]){
ApplicantCollection c=new ApplicantCollection();
c.displayCollection();}
};
//II
public class candidateCollection
{
String candidateName;
String candidateAddress;
String candidatePosition;
String interviewDate;
String candidateStatus;
public void displayDetails()
{
System.out.println(candidateName);
System.out.println(candidateAddress);
System.out.println(candidatePosition);
System.out.println(interviewDate);
System.out.println(candidateStatus);
}
Candidate appObject[];
public candidateCollection()
{
appObject=new Candidate[2];
for(int ctr=0;ctr!=appObject.length;ctr++)
{
appObject[ctr]=new Candidate();
}
appObject[0].candidateName="kassen";
appObject[0].candidateAddress="jining";
appObject[0].candidatePosition="Manager";
appObject[0].interviewDate="1999-9-9";
appObject[0].candidateStatus="AAAAAAAAAAA";
appObject[1].candidateName="maclen";
appObject[1].candidateAddress="jinan";
appObject[1].candidatePosition="Employee";
appObject[1].interviewDate="2002-2-22";
appObject[1].candidateStatus="BBBBBBBBBBB";
}
public void displayCollection()
{
for(int j=0;j!=appObject.length;j++)
{
appObject[j].displayDetails();
}
}
public static void main(String args[])
{
candidateCollection h=new candidateCollection();
h.displayCollection();
}
};
为什么I可以编译,并运行.而II却连编译也不可以,请给出详细的解释,谢谢~!
(附注:为什么我最高只能给出33分~!?)
public class ApplicantCollection
{
String applicantName;
String applicantAddress;
String applicantPosition;
public void displayDetails(){
System.out.println(applicantName);
System.out.println(applicantAddress);
System.out.println(applicantPosition);}
Applicant appObject[];
public ApplicantCollection(){
appObject=new Applicant[3];
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr]=new Applicant();
}
appObject[0].applicantName="汤姆";
appObject[0].applicantAddress="北京";
appObject[0].applicantPosition="manger";
appObject[1].applicantName="莹";
appObject[1].applicantAddress="济南";
appObject[1].applicantPosition="高级软件工程师";
appObject[2].applicantName="风";
appObject[2].applicantAddress="大连";
appObject[2].applicantPosition="软件工程师";}
public void displayCollection(){
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr].displayDetails();}}
public static void main(String args[]){
ApplicantCollection c=new ApplicantCollection();
c.displayCollection();}
};
//II
public class candidateCollection
{
String candidateName;
String candidateAddress;
String candidatePosition;
String interviewDate;
String candidateStatus;
public void displayDetails()
{
System.out.println(candidateName);
System.out.println(candidateAddress);
System.out.println(candidatePosition);
System.out.println(interviewDate);
System.out.println(candidateStatus);
}
Candidate appObject[];
public candidateCollection()
{
appObject=new Candidate[2];
for(int ctr=0;ctr!=appObject.length;ctr++)
{
appObject[ctr]=new Candidate();
}
appObject[0].candidateName="kassen";
appObject[0].candidateAddress="jining";
appObject[0].candidatePosition="Manager";
appObject[0].interviewDate="1999-9-9";
appObject[0].candidateStatus="AAAAAAAAAAA";
appObject[1].candidateName="maclen";
appObject[1].candidateAddress="jinan";
appObject[1].candidatePosition="Employee";
appObject[1].interviewDate="2002-2-22";
appObject[1].candidateStatus="BBBBBBBBBBB";
}
public void displayCollection()
{
for(int j=0;j!=appObject.length;j++)
{
appObject[j].displayDetails();
}
}
public static void main(String args[])
{
candidateCollection h=new candidateCollection();
h.displayCollection();
}
};
为什么I可以编译,并运行.而II却连编译也不可以,请给出详细的解释,谢谢~!
(附注:为什么我最高只能给出33分~!?)
|
你的程序太乱了,第一个也不能通过,我将它们改正如下并测试通过,你可以参考一下:
//I
class Applicant
{
String applicantName;
String applicantAddress;
String applicantPosition;
public void displayDetails(){
System.out.println(applicantName);
System.out.println(applicantAddress);
System.out.println(applicantPosition);
}
};
public class ApplicantCollection
{
Applicant appObject[];
public ApplicantCollection(){
appObject=new Applicant[3];
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr]=new Applicant();
}
appObject[0].applicantName="汤姆";
appObject[0].applicantAddress="北京";
appObject[0].applicantPosition="manger";
appObject[1].applicantName="莹";
appObject[1].applicantAddress="济南";
appObject[1].applicantPosition="高级软件工程师";
appObject[2].applicantName="风";
appObject[2].applicantAddress="大连";
appObject[2].applicantPosition="软件工程师";
}
public void displayCollection(){
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr].displayDetails();
}
}
public static void main(String args[])
{
ApplicantCollection c=new ApplicantCollection();
c.displayCollection();
}
};
//II
class Candidate
{
String candidateName;
String candidateAddress;
String candidatePosition;
String interviewDate;
String candidateStatus;
public void displayDetails()
{
System.out.println(candidateName);
System.out.println(candidateAddress);
System.out.println(candidatePosition);
System.out.println(interviewDate);
System.out.println(candidateStatus);
}
};
public class candidateCollection
{
Candidate appObject[];
public candidateCollection()
{
appObject=new Candidate[2];
for(int ctr=0;ctr!=appObject.length;ctr++)
{
appObject[ctr]=new Candidate();
}
appObject[0].candidateName="kassen";
appObject[0].candidateAddress="jining";
appObject[0].candidatePosition="Manager";
appObject[0].interviewDate="1999-9-9";
appObject[0].candidateStatus="AAAAAAAAAAA";
appObject[1].candidateName="maclen";
appObject[1].candidateAddress="jinan";
appObject[1].candidatePosition="Employee";
appObject[1].interviewDate="2002-2-22";
appObject[1].candidateStatus="BBBBBBBBBBB";
}
public void displayCollection()
{
for(int j=0;j!=appObject.length;j++)
{
appObject[j].displayDetails();
}
}
public static void main(String args[])
{
candidateCollection h=new candidateCollection();
h.displayCollection();
}
};
//I
class Applicant
{
String applicantName;
String applicantAddress;
String applicantPosition;
public void displayDetails(){
System.out.println(applicantName);
System.out.println(applicantAddress);
System.out.println(applicantPosition);
}
};
public class ApplicantCollection
{
Applicant appObject[];
public ApplicantCollection(){
appObject=new Applicant[3];
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr]=new Applicant();
}
appObject[0].applicantName="汤姆";
appObject[0].applicantAddress="北京";
appObject[0].applicantPosition="manger";
appObject[1].applicantName="莹";
appObject[1].applicantAddress="济南";
appObject[1].applicantPosition="高级软件工程师";
appObject[2].applicantName="风";
appObject[2].applicantAddress="大连";
appObject[2].applicantPosition="软件工程师";
}
public void displayCollection(){
for(int ctr=0;ctr!=appObject.length;ctr++){
appObject[ctr].displayDetails();
}
}
public static void main(String args[])
{
ApplicantCollection c=new ApplicantCollection();
c.displayCollection();
}
};
//II
class Candidate
{
String candidateName;
String candidateAddress;
String candidatePosition;
String interviewDate;
String candidateStatus;
public void displayDetails()
{
System.out.println(candidateName);
System.out.println(candidateAddress);
System.out.println(candidatePosition);
System.out.println(interviewDate);
System.out.println(candidateStatus);
}
};
public class candidateCollection
{
Candidate appObject[];
public candidateCollection()
{
appObject=new Candidate[2];
for(int ctr=0;ctr!=appObject.length;ctr++)
{
appObject[ctr]=new Candidate();
}
appObject[0].candidateName="kassen";
appObject[0].candidateAddress="jining";
appObject[0].candidatePosition="Manager";
appObject[0].interviewDate="1999-9-9";
appObject[0].candidateStatus="AAAAAAAAAAA";
appObject[1].candidateName="maclen";
appObject[1].candidateAddress="jinan";
appObject[1].candidatePosition="Employee";
appObject[1].interviewDate="2002-2-22";
appObject[1].candidateStatus="BBBBBBBBBBB";
}
public void displayCollection()
{
for(int j=0;j!=appObject.length;j++)
{
appObject[j].displayDetails();
}
}
public static void main(String args[])
{
candidateCollection h=new candidateCollection();
h.displayCollection();
}
};
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。