Hi:
I am writing a for loop, and I want it to stop when a specific String entered by a user.The problem is it does not stop. I tried the loop using an integer entry instead and the loop does stop. But I need to use a String as a stopping signal.
Thanks in advance for the help.
import java.util.*;
class Roulette
{
public static void main (String [] args)
{
System.out.println("\nWelcome to Roulette!");
System.out.println("First type the name of the players."); System.out.println("When you are done entering their name,
just hit enter a blank line to continue.\n");
String [] player = new String [50];
int [] startMoney = new int [50];
Scanner keyboard = new Scanner(System.in);
for(int i=1; i < 50; i++)
{
System.out.println("What is the Name of Player #"+i+"?");
String s = keyboard.next();
if (s == "no") i = 50;
else
{
player[i] = s; System.out.println("How much money does " + player[i] + " start off
with? ");
startMoney[i] = keyboard.nextInt();
}
}
}
}
~