Java Code - Appostrophe (most likely spelled wrong)


In the code found below, Can someon tell me what the apostrophe is used for? What is its purpose?

resp = resp + "<BusinessName id='"+BusinessId+"'>"+BusinessName+"</BusinessName>";
LVL 3
gazdzidAsked:
Who is Participating?
 
kadabaCommented:
"<BusinessName id='"+BusinessId+"'>"+BusinessName+"</BusinessName>"
"<BusinessName id='1'>Sample Business Name</BusinessName>"

resp = resp -- indicates concatenation with older entry present in resp
+ -- concatenate
"<BusinessName id='" -- This will indicate one string
+ -- concatenate
BusinessId -- The business Id to be used
+ -- concatenate
"'>" -- one more part of the string
+ -- concatenate
BusinessName -- The business name
+ -- concatenate
"</BusinessName>"

So a string would be inside ""

now we have

"<BusinessName id='" -- a single quote after the equals sign/ apostrophe
"'>" -- similarly here
This is used because id is an attribute of the BusinessName and all XML attribute values must be quoted
like id='1' or id = "1"

if we need to add "" double quotes we need to escape it with \
"<BusinessName id=\""+BusinessId+"\">"+BusinessName+"</BusinessName>"

hence the above snytax.

Hope this is clear.
0
 
Sathish David Kumar NArchitectCommented:
eg:
think  initialzly resp=5


now as ur give
ur going to assign new value to resp !!

resp + "<BusinessName id='"+BusinessId+"'>"+BusinessName+"</BusinessName>";
 
+  for concatenate the strings ..

<BusinessName>  tag ur  using !!
</BusinessName> close the tag !!

property is id

u want to assign string value to id ..

so ' " +BusinessId+" '  

0
 
gazdzidAuthor Commented:
I would like to review before assigning points. sorry for the delay
0
 
gazdzidAuthor Commented:
I agree with moderator.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.