• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

string variable

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone tell me what is the deference between

str a = "abc"


str a ="+i+";

what is the double + means?
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing. It's just a string.
 
Ranch Hand
Posts: 41
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "+" won't do anything while inside the quotation marks - it's just text, a string literal. The only character that has any effect in the string literal is "\".
 
kahkean chor
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
erm.....so what is the purpose of adding + for the sql statment?

is "SELECT * FROM Student WHERE StudentID = '" + stuID + "';"; equivalent to "SELECT * FROM Student WHERE StudentID = '" stuID "';";
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kahkean chor wrote:erm.....so what is the purpose of adding + for the sql statment?


Completely different question.

Answer: usually to include the value of a variable; although it's not the best way to do it. Have a look at PreparedStatement.

And BTW: How do you imagine we're supposed to know that your strings are part of an SQL statement?

is "SELECT * FROM Student WHERE StudentID = '" + stuID + "';"; equivalent to "SELECT * FROM Student WHERE StudentID = '" stuID "';";


No; because that 2nd statement won't compile.

Winston
 
kahkean chor
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so sad i dont get it....btw thanks for your reply
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic