Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make a .toLowerCase work in this particular case.. Seems not to work at all
    primarykey
    data
    text
    <p>So i've always been having problems with .toLowerCase and I've checked loads of articles, Videos and books on how it works. I tried making a silly game as a joke for my friends and obviously this wont work</p> <p>What's the best way to fix it and how do i .toLowerCase() work? If a simple explanation could be given i'd be very happy!! :)</p> <p>the "Choice " is a static String.</p> <pre><code>public static void part1() { System.out.println("Welcome to Chapter ONE "); System.out.println("This is just a simple Left Right options."); System.out.println("-------------------------"); System.out.println("You emerge into a cave like structure, It's seems very weird and creeps you out a little, Yet, You continue on your journey \n You see a that you have reached a 'Dead End' and \n now you have two choices: Either go Left into the weird corner, Or Go Right.. Into the Well-Lit Area."); choice = input.next(); if(choice.toLowerCase()=="left") { deathPre(); } else if(choice.toLowerCase()=="right") { TrFight(); } } </code></pre> <p>So this is the part where it doesnt work (Yeah, It's the first part ironically)i've tried other ways to make this work. Though this being the simplest for me to do suddenly became impossible.</p> <p>Please help!</p> <p>Logic : If the user inputs "Left" (doesnt matter which case because i convert it to lower case either way).. It should send the user to "deathPre(); And if he inputs "right" it should go to "TrFight(); Anything else causes an error which i dont mind. But i need the "Left" and "Right" to work</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload