Skip to content

Instantly share code, notes, and snippets.

@javadabadoo
Created September 4, 2012 23:27
Show Gist options
  • Save javadabadoo/3628020 to your computer and use it in GitHub Desktop.
Save javadabadoo/3628020 to your computer and use it in GitHub Desktop.
Demostracion de como funcionan los operadores logicos en Java
public static void main(String[] args) {
System.out.println("-- -- -- OR -- -- --");
if(bol(1, true) | bol(2, true));
System.out.println();
if(bol(1, false) | bol(2, false));
System.out.println("-- -- -- XOR -- -- --");
if(bol(1, true) || bol(2, true));
System.out.println();
if(bol(1, false) || bol(2, false));
System.out.println("-- -- -- AND -- -- --");
if(bol(1, false) & bol(2, false));
System.out.println();
if(bol(1, true) & bol(2, true));
System.out.println("-- -- -- XAND -- -- --");
if(bol(1, false) && bol(2, false));
System.out.println();
if(bol(1, true) && bol(2, true));
}
private static boolean bol(int indice, boolean retorno) {
System.out.printf("Imprimiento que el valor de %d es %b%n", indice, retorno);
return retorno;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment