My loop executes when when the condition is not met?

I’m reading through a txt file that looks like this:

H yes Billie Boolean yes 8 21 1924 623456.71 25 1993 25
O Cleveland 77.8 7 Ingrid Interface no 5 20 1978 234567.50 15 2002 221
S 127 92.1 2 Vince Vector yes 12 13 1959 2345678.20 31 1993 87
S 92 80.5 1 Mary Method no 8 20 1924 2267890.53 24 1992 25
O New York 83.6 14 Frank Forloop yes 3 24 1910 134212.00 32 1994 239
H yes Alan Aypeeeye no 7 2 1979 23456728.06 20 1999 120
S 64 90.5 12 Freda Floatingpoint no 6 23 1972 45678902.76 17 1990 87
O JavaVille 100.0 1 Connie Constructor yes 2 22 1941 138765.22 8 2001 221
S 126 75.4 10 Albert Abstract no 7 11 1934 245876.90 25 1993 239
O Java Variable Village 76.1 18 Iffy Ifelse yes 7 16 1907 16727.00 40 1986 87
S 149 83.6 1 Artie Args yes 1 9 1902 12345.50 34 1986 120
S 162 92.4 3 Stacey StringBuilder no 3 28 1948 18765324.10 12 2008 221
H no Stan StringBuffer yes 11 28 1939 209876541.11 21 1996 239
H yes Pollie Polymorphism no 10 22 1925 100982241.22 18 2006 25
O Chicago 100.0 1 Artie Array no 8 9 1955 500892227.10 26 1989 239
H no Colleen Collection no 8 20 1925 678895431.78 20 1997 87
S 65 84.6 8 Brandon Break no 9 30 1939 2345678.10 6 2010 87
O Cleveland Heights 76.9 17 Jerry Jayveeem yes 2 27 1925 200001.10 19 2008 221
S 162 77.8 5 Raymond Reference no 3 22 1958 32234907.20 17 2001 25
H yes Otto Boxing no 7 18 1977 6578900.80 3 2006 25


switch(strLine.charAt(0)){

   case 'O':
	String tempVar = " ";
	char tempVarChar = 'a';
						
	memberType = tokens.nextToken();
	birthCity = tokens.nextToken();
					
	while(tempVarChar != '0' || tempVarChar != '1' || tempVarChar != '2' || tempVarChar != '3' || tempVarChar != '4' || tempVarChar != '5' || tempVarChar != '6' || tempVarChar != '7' || tempVarChar != '8' || tempVarChar != '9' ){
							
		birthCity = birthCity.concat(tempVar).concat(" ");
		tempVar = tokens.nextToken();
		tempVarChar = tempVar.charAt(0);
	}
}

I used break points and step over to follow the variable tempVarChar. When tempVarChar becomes any of the char values listed in the condition it still executes the body. For example, I used a breakpoint to check the value of tempVarChar when it becomes ‘7’. It checks the condition and still passes the condition even though I stated tempVarChar != ‘7’ as one of the conditions. Any suggestions?

btw memberType and birthCity are declared outside the switch statement.

A: Your while can be vastly simplified with Character.isDigit()

B: Given that the last O type city is a gotcha, I’m thinking that tokenizing the Strings on spaces isn’t going to work for you. Edit: Doh, trying to handle that exception is exactly why you’re in this pickle, disregard.

C: Let’s see if I understand the assignment: You have a file of member records of different types, the type determines the format of the record, you are to populate a member Object by parsing the records correctly for each type. How’d I do?

D: To answer your question, your while says “while any of the following conditions are true, continue looping”, when tempVarChar == 7, it is != [0,6]&[8,9], which, as should now be obvious, causes your loop to continue. You now have a choice: use isDigit to simplify, or replace all the ORs with ANDs.

E: while(this OR that ) will continue if this or that is true, while(this AND that) will only continue when this and that are true. Savvy?

Thank you!