Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Really need help user input of words  RSS feed

 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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 ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.

 
Campbell Ritchie
Marshal
Posts: 55715
163
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 55715
163
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!