Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

No.10 note in Scwcd Hints is wrong?

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read this on Scwcd Hints

10) ${"Not a Number"+ 3.0}. You will get a javax.servlet.jsp.el.ELException, complaining that Not a Number; cannot be converted to a java.lang.Double value. This example also goes to show that the addition operator in EL -unlike Java- is not overloaded to handle string concatenation. There's no operator overloading or string concatenation in EL.



but i also read this on head first book at page 428 mock question 6

${list["listIdx" + 1]} , ("listIdx" + 1) becomes a String ~



I am confused now...

anyone got any ideas?

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

${list["listIdx" + 1]} , ("listIdx" + 1) becomes a String


I don't think it will. "listIdx" + 1 should be evaluated as an Integer, thus an error occurs.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
consider,
${list['listIdx'+1]}

here, 'listIdx' is a string in ['listIdx'+1]. EL will try to coerce 'listIdx' to a long which is not possible.

The character inside the quotes should be a digit [0-9] .
i.e,
${list['1'+1]} would be converted to ${list[2]}

Thanks,
Nitin.
 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what the HFSJ book said is incorrect?
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many mistakes. Have a look on errata.
 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic