Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array and condition problem

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array which contains the names of days read from a line in a test file which contains other information, such as time etc.

For example,

com1402, Dr Andy Gordon, Monday, 0900

(The purpose being to record when a lectuer is to take place)

The code is written below


I KNOW that lecDayArray[0] holds the string "Monday". However, the above returns the word "No", although it should return "Yes". What is wrong with my code?
[ February 26, 2006: Message edited by: Sam Bluesman ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use lecDayArray[0].equals("Monday") instead of lecDayArray[0] == "Monday"
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers for that!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic