Results 1 to 4 of 4

Thread: Or method?

  1. #1
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

  2. #2
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

    Default Re: Or method?

    Is there anyway cause every time I have to make for example like this I always use if else to determine the or:
    Java Code:
    if (y.equals("y")){
    System.out.println("Yes!");
    }
    else if(y.equals("Y")) {
    System.out.println("Yes!");
    }
    else{
    System.out.println("ERROR");
    }
    The else if would be deleted if there is like or method for ex:
    Java Code:
    if (y.equals("y") or ("Y")){
    System.out.println("TEST");
    }
    I tried the or and there is no such thing in it so I was wondering if there is but need to write symbols.

  3. #3
    Join Date
    Jul 2011
    Posts
    30
    Rep Power
    0

    Default Re: Or method?

    Do you mean the OR operator?

    Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

    i.e. in code form

    Java Code:
    if (x = 1) || (y = 1) {
     do this
    }
    Sorry if I've misunderstood your question.

    Regards Serb.

  4. #4
    micolord is offline Member
    Join Date
    Sep 2011
    Location
    Philippines
    Posts
    41
    Rep Power
    0

    Default Re: Or method?

    Quote Originally Posted by SerbianSergeant View Post
    Do you mean the OR operator?

    Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

    i.e. in code form

    Java Code:
    if (x = 1) || (y = 1) {
     do this
    }
    Sorry if I've misunderstood your question.

    Regards Serb.
    THANKS SO MUCH! +rep.

Similar Threads

  1. Declaring a method inside a method: Runnable?
    By africanhacker in forum New To Java
    Replies: 8
    Last Post: 03-23-2011, 05:30 AM
  2. Turning Recursion Method into Iterative method
    By mattakuevan in forum New To Java
    Replies: 9
    Last Post: 06-15-2010, 07:46 AM
  3. Replies: 2
    Last Post: 03-26-2010, 06:12 PM
  4. ArrayLists compareTo method, equals method
    By random0munky in forum New To Java
    Replies: 2
    Last Post: 10-26-2009, 08:20 PM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •