Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

what is this

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friendz,
can anybody explain these mentioned line of code. where i m wrong...
1. String a="one";
String b=a.concat(a); //result is oneone
if (a=="one") //true ok i m satisfied coz same string pool
if (b=="oneone") //false what is that even both b and "oneone" same string pool

2.String c=" one ";
if (c.trim()=="one") //false ??? anybody explain
if (c.trim()==c.trim()) //still false what is that ???
plz give me detail both above questions.
thanx
Aftab
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.
concat() returns a "new" string which is not in the string pool
although you can intern it into the pool.
2.
trim() also returns a new string unless there is nothing
to trim in which case, it returns the original string. In fact,
every time you call trim (as you did below), it always returns
a "new"
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic