0

I created two arrays in that stored two array of string values now I want to compare by using if condition please help me.

I did like this....

String[] source={"Chennai","Bangalore","Hyderabad"};

String[] destination={"Chennai","Bangalore","Hyderabad"};

if(source[0] == "Chennai" && destination[2] == "Hyderabad") {
      //Here i want to print some thing  
}
V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
chandu
  • 45
  • 1
  • 7
  • now I want to compare by using if condition - what do you want to compare. what is string here? – Nongthonbam Tonthoi Jun 09 '16 at 05:56
  • what you need to compare? is it by index of arrays of just hardcoding values? – tarzanbappa Jun 09 '16 at 05:56
  • Try using String[] destination={"Chennai","Bangalore","Hyderabad"}; String[] source={"Chennai","Bangalore","Hyderabad"}; if(source[0].equalsIgnoreCase("Chennai") && destination[2].equalsIgnoreCase("hyderabad")) { /*Add your code*/ } – Reena Jun 09 '16 at 06:05

1 Answers1

0

Try this:

if(source[0].equals("Chennai") && destination[2].equals("Hyderabad"))
  {
      Here i want to print some thing  
  }
Khizar Hayat
  • 3,427
  • 3
  • 18
  • 22