Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts
Tuesday, 9 July 2019
Friday, 5 July 2019
Wednesday, 14 November 2018
Saturday, 28 November 2015
SwitchCase statement in Java
package day1.examples;
public class ExampleSwitchCase {
public static void main(String[] args) {
int j = 2;
switch (j) {
case 0:
System.out.println("Value is 0");
break;
case 1:
System.out.println("Value is 1");
break;
case 2:
System.out.println("Value is 2");
break;
default :
System.out.println("No Value");
break;
}
}
}
package day1.examples;
public class ExampleSwitchCase {
public static void main(String[] args) {
String j = "Two";
switch (j) {
case "Zero":
System.out.println("Value is 0");
break;
case "One":
System.out.println("Value is 1");
break;
case "Two":
System.out.println("Value is 2");
break;
default :
System.out.println("No Value");
break;
}
}
}
And Or in Java
package day1.examples;
public class ExampleAndOr {
public static void main(String[] args) {
int x, y;
x = 10;
y = -10;
// && And
// || Or
if (x > 0 && y > 0) {
System.out.println("Both Numbers are
Positive");
} else if (x > 0 || y > 0) {
System.out.println("Atleast One number
is Positive");
System.out.println(" -- By Lokanadham Thandlam");
}
}
}
If Statement in Java Language
package day1.examples;
public class ExampleIf {
public static void main(String[] args) {
System.out.println("Hello Lokanadham
Thandlam");
int x = 20;
int y = 40;
if (x == y) {
System.out.println(" X is equal to
Y");
} else if (x > y) {
System.out.println("X is Greater to
Y");
}
else if (x < y) {
System.out.println("X is Less than
Y");
}
}
}
Subscribe to:
Comments (Atom)