• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Synchronizing Block code

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi guys, this is the exercise 9 -2 on pg 710 of k & b. I did a comparison at line 1 and change the StringBuffer object. Is there any other way to do the comparison and increment the letter?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

You could try something like:


Giovanni
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This particular exercise baffled me, but for a different reason this time

The verbiage of the question states "You can check Chapter 6 for StringBuffer methods that will help with this." so I took it literally to mean that the only methods that applied to the exercise were the ones discussed in the StringBuffer/StringBuilder section in chapter 6.

The charAt() and setCharAt() methods were never discussed in the context of StringBuffers/StringBuilders in Chapter 6.
[ June 20, 2007: Message edited by: Brad Clarke ]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Giovanni Murguia:
Hello!

You could try something like:


Giovanni



i'm getting compiler error for the above code as follows:

cannot find symbol
symbol : method setCharAt(int, int)
location: class java.lang.StringBuffer
sb.setCharAt(0, letter+1);

i tested if i change it to the following it compiles fine:
sb.setCharAt(0, letter);

so what's wrong with the +1 there?
 
reply
    Bookmark Topic Watch Topic
  • New Topic