• 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

illegal character: \92

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying compile a class that I wrote. I get the following compile time exception:

I tried removing the semi-colon to see what other error it would give me, and it gives me the same error pointing now to the location that would have the semi-colon had it not been removed. I assumed this meant I somehow had a hidden character in there.
I deleted a lot of the text around that spot and retyped it, but I still get the same error.
I assume this is something very basic, and hopefully some of the long-timers have run into it before. Help please!
[ November 08, 2002: Message edited by: Michael Brewer ]
[ November 08, 2002: Message edited by: Michael Brewer ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right at the beginning of your string there is a closing quote: "<div class="
So the rest is crap to the compiler.
Frankly, don't write strings like that! Split them up nicely and concatenate them with the "+" operator.
-Barry
 
Sheriff
Posts: 67746
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
Or better yet, use StringBuffer to build up complex strings; much more efficient than String concatentation.
Or even better yet, don't build up markup in strings! Either use a template system like JSP, or if you must build markup in Java, explore the use of packages like Jakarta ECS that allow you to build a DOM representing your markup as objects, and then serialize it to html, xhtml or other markup.
hth,
bear
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that if you concatenate string CONSTANTS, the compiler shoves them all together as one big string. So concatenation can be used at no cost to make long string constants more readable, as in:

which compiles to exactly the same bytecodes as:

Using StringBuffer.append in the above situation would be less readable and acutally less efficient:


Note also that non-constant string concatenation on a single line of code compiles to a usage of StringBuffer. The following two lines of code compile to identical bytecodes (JDK 1.4 - others are similar):

Actually, in many cases, using String.concat() can be more efficient (faster and creates fewer objects) than the above StringBuffer gunk, as in:

Just in case you wanted to know....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic