• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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>";
0
gazdzid
Asked:
gazdzid
  • 2
1 Solution
 
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 NCommented:
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now