• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 67747
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
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic