• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Turning first word in scentence toUpperCase(nextWord.charAt(0)). Help?

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

I've been trying for several hours now... Can't get this line of code to work. It prints nextWord as it would without the code. It compiles just fine and my blueJ debugger leaves me with no clue.





Heres my whole for-loop:

 
Marshal
Posts: 77291
371
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

What you are doing is setting an element in a List (why the + 1?), then printing nextWord. Now, if nextWord is a String, then it cannot change. Rather than printing nextWord, print the List and see what happens.
 
tor-einar frostad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

What you are doing is setting an element in a List (why the + 1?), then printing nextWord. Now, if nextWord is a String, then it cannot change. Rather than printing nextWord, print the List and see what happens.



Thanks!
The +1 one is there because the integer I want to replace is the one after the the int index, wich contains() the characters "!", "." and "?". String nextWord = myList.get(i+1). The variable is declared inside the for-loop. So it should work, right??
 
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You set nextWord in line 3 then without changing it, you print it in line 7. Is this what you expected?
 
tor-einar frostad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:You set nextWord in line 3 then without changing it, you print it in line 7. Is this what you expected?




Guess it didn't work because the variable doesn't change with the index given to it. I thought it did. I would have to declare it again before printing it. It worked when I checked my list. Thank you
 
Campbell Ritchie
Marshal
Posts: 77291
371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done
 
Ranch Hand
Posts: 789
Python C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you break it up on different lines instead of chaining functions together you will have better luck with the debuggers I'm familiar with. No reason to not be able to debug it.
 
Campbell Ritchie
Marshal
Posts: 77291
371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Guillermo Ishi wrote:. . . No reason to not be able to debug it.

There might be; OP said he was using BlueJ


You may get the impression I don't like BlueJ. That would be correct.
reply
    Bookmark Topic Watch Topic
  • New Topic