Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to compare string Array with different string  RSS feed

 
sarika Gupta
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General(beginner).
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have two String[] and you want to compare whether both hold equal values or not, am I right?
 
sarika Gupta
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!