Skip to content

Instantly share code, notes, and snippets.

@ZacharyJacobCollins
Created October 23, 2016 21:32
Show Gist options
  • Save ZacharyJacobCollins/fef85805a666cf777a04951daf2706be to your computer and use it in GitHub Desktop.
Save ZacharyJacobCollins/fef85805a666cf777a04951daf2706be to your computer and use it in GitHub Desktop.
Java Operators
/**
*
* Testing all java operators to experience how they work
* bitwise: designating an operator in a programming language that manipulates the individual bits in a byte or word.
*
*/
public class Driver {
public static void main(String[] args) {
and();
// or();
ternary();
}
/**
* Operator: And &
* Description: And bitwise operation"
*/
public static void and() {
System.out.println("And bitwise operation");
byte b = (11111111 & 00000000);
System.out.println(b + "\n");
}
/**
* Operator: or
* Description: or bitwise operator
*/
public static void or() {
System.out.println("Or bitwise operation");
System.out.println();
}
/**
* Operator: Ternary
* Description: Shortened if else statement
*/
public static void ternary() {
System.out.println("ternary operator");
int guess = 1;
int answer = 2;
//if guess is equal to answer output correct, else output incorrect
System.out.println( ( guess == answer ? "correct" : "incorrect" ));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment