Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class HelloWorld{
  2.  
  3. public static void main(String []args){
  4. A a = new A();
  5. B b = new B();
  6. check(a, b);
  7. }
  8.  
  9. private static void check(A a, B b){
  10. if ( ( a.getX() != b.getY() && (a.getX() == null || b.getY() == null) )
  11. || ( a.getX() != null && !a.getX().equals(b.getY()) ) ) {
  12. System.out.println("IN");
  13. }
  14. }
  15. }
  16.  
  17. class A{
  18. String x = "1";
  19. public String getX(){
  20. return this.x;
  21. }
  22. }
  23. class B{
  24. String y = "2";
  25. public String getY(){
  26. return this.y;
  27. }
  28. }
  29.  
  30. // What I want to achieve:
  31. // pcs = null && mp = null -> skip
  32. // pcs = "1" && mp = "1" -> skip
  33. // pcs = null && mp = "1" -> enter
  34. // pcs = "1" && mp = null -> enter
  35. // pcs = "1" && mp = "2" -> enter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement