Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
class Example {
static void main(String[] args) {
int a = 00111100;
int b = 00001101;
int x;
println(Integer.toBinaryString(a&b));
println(Integer.toBinaryString(a|b));
println(Integer.toBinaryString(a^b));
a=~a;
println(Integer.toBinaryString(a));
}
}
class Example {
static void main(String[] args) {
def x = 5;
def y = 10;
def z = 8;
if(x == y) {
println("x is equal to y");
} else
println("x is not equal to y");
if(z != y) {
println("z is not equal to y");
} else
println("z is equal to y");
if(z != y) {
println("z is not equal to y");
} else
println("z is equal to y");
if(z<y) {
println("z is less than y");
} else
println("z is greater than y");
if(x<=y) {
println("x is less than y");
} else
println("x is greater than y");
if(x>y) {
println("x is greater than y");
} else
println("x is less than y");
if(x>=y) {
println("x is greater or equal to y");
} else
println("x is less than y");
}
}
class Example {
static void main(String[] args) {
// Initializing 3 variables
def x = 5;
def y = 10;
def z = 8;
//Performing addition of 2 operands
println(x+y);
//Subtracts second operand from the first
println(x-y);
//Multiplication of both operands
println(x*y);
//Division of numerator by denominator
println(z/x);
//Modulus Operator and remainder of after an integer/float division
println(z%x);
//Incremental operator
println(x++);
//Decrementing operator
println(x--);
}
}
class Example {
static void main(String[] args) {
//Initializing 2 variables
int x = 5;
int X = 6;
//Printing the value of the variables to the console
println("The value of x is " + x + "The value of X is " + X);
}
}
class Example {
static void main(String[] args) {
// Defining a variable in lowercase
int x = 5;
// Defining a variable in uppercase
int X = 6;
// Defining a variable with the underscore in it's name
def _Name = "Joe";
println(x);
println(X);
println(_Name);
}
}
class Example {
static void main(String[] args) {
// x is defined as a variable
String x = "Hello";
// The value of the variable is printed to the console
println(x);
}
}