File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Array and condition problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array and condition problem" Watch "Array and condition problem" New topic

Array and condition problem

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
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 ]

Moosey knows best
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Use lecDayArray[0].equals("Monday") instead of lecDayArray[0] == "Monday"

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Cheers for that!
It is sorta covered in the JavaRanch Style Guide.
subject: Array and condition problem
It's not a secret anymore!