-4

I want to write a boolean function call isDistrict (String districtCheck) {} and i need to use this method for checking district is the same as disrictCheck, if yes it will return turn and the other will return flase.but i hv no ideal to do this.

 public boolean isDistrict (String districtCheck) {
      // TODO: Missing logic. Help
 }

For example if I would have this String, where I would like to check for Kwun Tong: address:Room A,32/F,456 XXX,Kwun Tong,Kowloon districtCheck:Kwun Tong true When I would check for Hung Hom, I would get: districtCheck:Hung Hom false

chau123
  • 11
  • 1
  • 2
  • Just look for `indexOf` and if the index is higher then -1, then you have found the district. – Jernej K Apr 01 '16 at 18:55
  • 1
    Why don't you just Google something like "java check if string is in another string"? -1 for no research effort – tnw Apr 01 '16 at 18:57
  • Just research on Java String manipulation methods. That way you will learn more. – cdaiga Apr 01 '16 at 19:02
  • i'm sorry for that but i hv no ideal to do that i just know i can use the split or tokenizer to do that – chau123 Apr 02 '16 at 04:48

1 Answers1

0
 String address = "Room A,32/F,456 XXX,Kwun Tong,Kowloon"

 ...

 public boolean isDistrict (String districtCheck){
     return address.contains(districtCheck)
 }
Eugen Hotaj
  • 383
  • 2
  • 10