• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Problems with Item/String getting input?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if I am making no sense, I dont have much practise
Hello, I have set up Items to hold a set of chars which are meant to be placed on a text based map, however when i am asking for the char, there is an error stating that it must be a string type. Is there any way to convert my Items to strings, or allow the input of an Item? Thanks in advance
The error is where the user is trying to enter a symbol.

 
Sheriff
Posts: 7113
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
Quick answer: You can often use String.valueOf(something) to create a string out of another type, but I haven't tested it.
 
Marshal
Posts: 76397
364
  • 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

Lots of little things, I am afraid.
I had to break your line 119 because it was too long. Also your indentation and spaing are inconsistent which makes you r code hard to read: look at lines 100-107. Don't use \n unless you have been asked for the LF character. Even less
System.out.printf("\n");
Use
System.out.println();
instead. String.valueOf() will definitely work; it calls toString unless you manage to pass null in which case you get the String "null". You can probably get your Item objects via a valueOf method as well, assuming Item is an enumerated type.
 
John Bowmen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks:)
 
Let nothing stop you! Not even this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic