Top 10 Java Programs

    public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello World!”); } } Output: Hello World!

    public class VariablesInitialization { public static void main(String[] args) { // TODO code application logic here boolean flag=true; System.out.println(flag); System.out.println(“Flag=”+flag); […]

    public class JavaOperators { public static void main(String args[]) { System.out.println(“Example 1:——————————-“); //Java Unary Operator Example: ++ and — int […]

    °C = (°F – 32) / (9/5) import java.util.Scanner; public class JavaFarenheitToCelsius { public static void main(String[] args) { float […]

    import java.util.Scanner; public class JavaMarksAverage { public static void main(String[] args) { int math,english,science,art,computer,total,percent; Scanner sc=new Scanner(System.in); System.out.println(“Enter marks out […]

    Simple Interest = (Princple * Rate * Time)/100 import java.util.Scanner; public class JavaSimpleInterest { public static void main(String[] args) { […]

    Area of Circle = (22/7) X radius x radius import java.util.Scanner; public class JavaFindAreaCircle { public static void main(String[] args) […]

    Area of Rectangle= Length X Breadth import java.util.Scanner; public class JavaFindAreaRectangle { public static void main(String[] args) { int l,b,area; […]

    public class JavaSwap { public static void main(String[] args) { int a=10, b=20, temp; System.out.println(“Before swapping”); System.out.println(“value of a=”+a); System.out.println(“value […]

    public class JavaSwapWithTwoVars { public static void main(String[] args) { int a=10, b=20; System.out.println(“Before swapping”); System.out.println(“value of a=”+a); System.out.println(“value of […]