• 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

Strange output?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic