• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Really need help user input of words

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys i am just starting out in java and it is my first coding language so i am a complete novice. on thing i cant get me head around is everything seems to be numerical. If i wanted to say write a simple program where the user is asked to type in there favorite color How would i go about returning a different message for each colour ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Ultimately, the computer can only deal with numbers (if you look at a really low level, it only works with bits which can be 0 or 1). But in the Java programming language not everything is necessarily just numbers. You can use strings to work with text.

Here's an example.

 
Marshal
Posts: 76854
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome again

Have you come across the switch statement? Since Java7 it has been possible to work with Strings:-You can create a Map which can store names and addresses, but Maps are probably more advanced than you are after a few weeks.
 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much for the reply, you have cleared up something that has been troubling me for a while lol
 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maps? i know i am getting ahead of myself but i have a project in mind whilst learning java and storing info is something i would like to have a bit of insight into ?
 
Campbell Ritchie
Marshal
Posts: 76854
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome

You will probably learn about the Collections Framework later in your course. You can have a preview if you look in the Java™ Tutorials, and you will find Maps in there somewhere.
 
Right! We're on it! Let's get to work tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic