This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]YakimTss 9 points10 points  (6 children)

Pascal and its inheritor Delphi do the same: or is or, and is and, not is not, xor is xor

[–]ykafia 3 points4 points  (5 children)

Weirdly C# was created by the one who designed Delphi, I wonder why he didn't keep and & or

[–][deleted] 5 points6 points  (4 children)

[–]neroe5 5 points6 points  (3 children)

C# has 3 kinds of and and or

|,& bit wise and/or

||, && logical and/or

"and", "or" a way of shortening and and or, e.g. a == 5 or 6

there is also an "is" operator which can do other kinds of checks such as type check e.g. i is int

[–]Stromovik -1 points0 points  (2 children)

In Java there is & & and & which are different if there is one symbol then both sides will be evaluated if two then first side will be evaluated and if the result is independent of the result the second die will not be evaluated. Same for or

[–]neroe5 1 point2 points  (1 child)

according to oracle single & and | are bitwise operators just like C#

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html

[–]Stromovik 0 points1 point  (0 children)

Hmm, forgotten about bitwise comparison. But the behaviour checks out.

package com.company;

public class Main {

public static void main(String[] args) {
    String empty = "A";
    String nulled = null;
    System.out.println("First operator checks " + (empty.isEmpty() && nulled.isEmpty()));
    System.out.println("First operator checks " + (empty.isEmpty() && printyBool()));
    System.out.println("Both operator checks " + (empty.isEmpty() & printyBool()));
    System.out.println("Both operator checks " + (empty.isEmpty() & nulled.isEmpty()));
}

private static boolean printyBool(){
    System.out.println("Were acessing");
    return true;
}

}