This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class conversion to string

 
BHAVESH SHA
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected Sir,

I have created one package where hierarchy of class starts from Application below that class i have created other two classes i.e. call A and B,

Now When i m trying to execute A and B classes in Application class and trying to convert into string but it is giving me error type mismatch so can you please share method which would solve my problem

Looking forward for your favourable reply soon

Regards

Bhavesh Shah
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't quite understand your question. Can you post some code (using code tags) and explain exactly what you are trying to convert into a string.
 
BHAVESH SHA
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir ,
I have package named model in which
Top level Class Application and other two classes are below it
i.e Applicant,Deviation

code :
public class Application implements Serializable, ComparisionDifferencesCollector {
private Applicant[] applicants;
private Deviation[] deviations;

public Applicant[] getApplicants() {
return applicants;
}
public void setApplicants(Applicant[] applicants) {
this.applicants = applicants;
}
...
}

public class TestParser {
public static void main(String args[]){
APSBusinessDataDAO buildApplicationDAO = new APSBusinessDataJDBCImplementation();
Application application = buildApplicationDAO.buildApplication("51715486");
String applicant= application.getApplicants();
String deviation= application.getDeviation().

I required to convert applicant to String format as it shows the error:
Type mismatch: cannot convert from Applicant[] to String

Kindly suggest for the same .
Thanks and regards
Bhavesh Shah
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

1. you was trying to convert array object to string.you can not do it..
directly..you need to type cost and you have to assign it to an array String.

String[] str=(String[])Object[]

you try with this concept

thanks & regards,
seetharaman
 
BHAVESH SHA
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for help , i tried your code
i.e
String[] applicant = ((String[])application.getApplicants());(in main class)
but error show
Cannot cast from Applicant[] to String[].

Kindly suggest it i have integrated wrong place .

Waiting for your reply
Thanks and Regards,.

Bhavesh Shah
 
pavan kumar seeram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why cant you try this............
String[] applicant = (application.getApplicants().toString());
 
qingwu wang
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to do that, you have much work to do.
You can add a method invoke your get method and translate to String array type.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic