Two Laptop Bag
The moose likes Beginning Java and the fly likes how to compare string Array with different string Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how to compare string Array with different string" Watch "how to compare string Array with different string" New topic
Author

how to compare string Array with different string

sarika Gupta
Greenhorn

Joined: Apr 27, 2005
Posts: 18
Hi,
I know it is very easy and basic but i have problem.
So please can you help me .
I want to compare array of string with different type of strings
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56152
    
  13

Moved to Java in General(beginner).


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
You have two String[] and you want to compare whether both hold equal values or not, am I right?


My blood is tested +ve for Java.
sarika Gupta
Greenhorn

Joined: Apr 27, 2005
Posts: 18
no i have one String[]and i want to compare it with different strings

for example
String[]department="account,It,marketing"
and i want to compare it with all Strings-: Account,It,Marketing
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1697
Question is not clear to me. Can you be more specific.

I understood you have array of strings String[] deparment and want to compare with another array of strings. Am I correct?
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by sarika Gupta:
no i have one String[]and i want to compare it with different strings

for example
String[]department="account,It,marketing"
and i want to compare it with all Strings-: Account,It,Marketing


So you have variables like account, it and marketing?
Since you know the position of account for example you can simply say

That assumes account is at 0, consider using a constant for that like ACCOUNT_POSITION = 0
Better yet create a Department object and then you can compare by saying department.getAccount().equals(account)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: how to compare string Array with different string
 
Similar Threads
Compare string to a String in array
Compare Array with String
sum of two int arrays
RegularExpression Pattern
Can I sort String arrays?