Java Code - Appostrophe (most likely spelled wrong)

Posted on 2010-01-07
Last Modified: 2013-11-24

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>";
Question by:gazdzid
    LVL 22

    Accepted Solution

    "<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

    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.
    LVL 20

    Expert Comment

    by:Sathish David Kumar N
    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+" '  

    LVL 3

    Author Comment

    I would like to review before assigning points. sorry for the delay
    LVL 3

    Author Closing Comment

    I agree with moderator.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now