• Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange output?  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently working on a project that turns a body of text into Pig Latin, in lowercase without punctuation. My code is as follows:



This is the Driver class.



This is the actual Piglatin class. It does pretty much all of the heavy lifting for the program.

The problem comes when the program is run. It compiles with no difficulty, but when it is supposed to give output, it puts in a set of strange characters.

For example: given the input "Eek! Scary Skeletons," the printed result is "[C@14eac69say."

If anyone has insight as to what the problem could be, I'd be glad to hear it.
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That strange output is how Java outputs an array.

These two lines do not do the same thing:


The first outputs your "strange" output. The second outputs the characters separated by commas. Neither seems like what you want so try a loop.
 
William Coville
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:That strange output is how Java outputs an array.

These two lines do not do the same thing:


The first outputs your "strange" output. The second outputs the characters separated by commas. Neither seems like what you want so try a loop.


That seemed to fix the specific output I was getting. There are some other problems with the code though. It doesn't even touch words that begin with vowels. Is something wrong with my if statement?

In addition, the code seems to only be changing one word in a string, despite the use of a String Tokenizer in the Piglatin class being used to split a string into multiple tokens, and the nextToken command being placed inside a loop. Does anyone happen to know how to fix these details?

 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use a thread title which tells people what the question is about. You can find better thread titles here, for example.
And it just so happens that thread title has “Pig Latin” in. Have a look how that other person solved Pig Latin and it might help with your problem.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!