The following issues were found

lectures/7-methods/code/src/com/kunal/Main.java
40 issues
System.out.print is used
Design

Line: 12

                      Scanner in = new Scanner(System.in);
        int num1, num2, sum;

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

            

Reported by PMD.

System.out.print is used
Design

Line: 14

              
        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");

            

Reported by PMD.

System.out.println is used
Design

Line: 17

                      System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();

            

Reported by PMD.

System.out.print is used
Design

Line: 19

                      sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

            

Reported by PMD.

System.out.print is used
Design

Line: 21

              
        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");

            

Reported by PMD.

System.out.println is used
Design

Line: 24

                      System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();

            

Reported by PMD.

System.out.print is used
Design

Line: 26

                      sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

            

Reported by PMD.

System.out.print is used
Design

Line: 28

              
        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");

            

Reported by PMD.

System.out.println is used
Design

Line: 31

                      System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();

            

Reported by PMD.

System.out.print is used
Design

Line: 33

                      sum = num1 + num2;
        System.out.println("The sum = " + sum);

        System.out.print("Enter number 1: ");
        num1 = in.nextInt();
        System.out.print("Enter number 2: ");
        num2 = in.nextInt();
        sum = num1 + num2;
        System.out.println("The sum = " + sum);

            

Reported by PMD.

lectures/6-conditions-loops/code/src/com/kunal/Calculator.java
32 issues
System.out.print is used
Design

Line: 12

                      int ans = 0;
        while (true) {
            // take the operator as input
            System.out.print("Enter the operator: ");
            char op = in.next().trim().charAt(0);

            if (op == '+' || op == '-' || op == '*' || op == '/' || op == '%') {
                // input two numbers
                System.out.print("Enter two numbers: ");

            

Reported by PMD.

System.out.print is used
Design

Line: 17

              
            if (op == '+' || op == '-' || op == '*' || op == '/' || op == '%') {
                // input two numbers
                System.out.print("Enter two numbers: ");
                int num1 = in.nextInt();
                int num2 = in.nextInt();

                if (op == '+') {
                    ans = num1 + num2;

            

Reported by PMD.

System.out.println is used
Design

Line: 41

                          } else if (op == 'x' || op == 'X') {
                break;
            } else {
                System.out.println("Invalid operation!!");
            }
            System.out.println(ans);
        }
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 43

                          } else {
                System.out.println("Invalid operation!!");
            }
            System.out.println(ans);
        }
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 5

              
import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {

            

Reported by PMD.

The class 'Calculator' has a Modified Cyclomatic Complexity of 11 (Highest = 10).
Design

Line: 5

              
import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {

            

Reported by PMD.

The class 'Calculator' has a Standard Cyclomatic Complexity of 11 (Highest = 10).
Design

Line: 5

              
import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {

            

Reported by PMD.

The method 'main(String)' has a cyclomatic complexity of 15.
Design

Line: 6

              import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {
            // take the operator as input

            

Reported by PMD.

The method 'main' has a Modified Cyclomatic Complexity of 10.
Design

Line: 6

              import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {
            // take the operator as input

            

Reported by PMD.

The method 'main' has a Standard Cyclomatic Complexity of 10.
Design

Line: 6

              import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Take input from user till user does not press X or x
        int ans = 0;
        while (true) {
            // take the operator as input

            

Reported by PMD.

lectures/7-methods/code/src/com/kunal/Scope.java
24 issues
System.out.println is used
Design

Line: 11

                      {
//                int a = 78; // already initialised outside the block in the same method, hence you cannot initialise again
                a = 100; // reassign the origin ref variable to some other value
            System.out.println(a);
                int c = 99;
                name = "Rahul";
            System.out.println(name);
                // values initialised in this block, will remain in block
        }

            

Reported by PMD.

System.out.println is used
Design

Line: 14

                          System.out.println(a);
                int c = 99;
                name = "Rahul";
            System.out.println(name);
                // values initialised in this block, will remain in block
        }
        int c = 900;
        System.out.println(a);
        System.out.println(name);

            

Reported by PMD.

System.out.println is used
Design

Line: 18

                              // values initialised in this block, will remain in block
        }
        int c = 900;
        System.out.println(a);
        System.out.println(name);
//        System.out.println(c); // cannot use outside the block

        // scoping in for loops
        for (int i = 0; i < 4; i++) {

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                      }
        int c = 900;
        System.out.println(a);
        System.out.println(name);
//        System.out.println(c); // cannot use outside the block

        // scoping in for loops
        for (int i = 0; i < 4; i++) {
//            System.out.println(i);

            

Reported by PMD.

System.out.println is used
Design

Line: 28

                          int num = 90;
            a = 10000;
        }
        System.out.println();
    }

    static void random(int marks) {
        int num = 67;
        System.out.println(num);

            

Reported by PMD.

System.out.println is used
Design

Line: 33

              
    static void random(int marks) {
        int num = 67;
        System.out.println(num);
        System.out.println(marks);
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 34

                  static void random(int marks) {
        int num = 67;
        System.out.println(num);
        System.out.println(marks);
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              package com.kunal;

public class Scope {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        String name = "Kunal";
        {
//                int a = 78; // already initialised outside the block in the same method, hence you cannot initialise again

            

Reported by PMD.

The initializer for variable 'a' is never used (overwritten on line 10)
Design

Line: 5

              
public class Scope {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        String name = "Kunal";
        {
//                int a = 78; // already initialised outside the block in the same method, hence you cannot initialise again
                a = 100; // reassign the origin ref variable to some other value

            

Reported by PMD.

Avoid unused local variables such as 'b'.
Design

Line: 6

              public class Scope {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        String name = "Kunal";
        {
//                int a = 78; // already initialised outside the block in the same method, hence you cannot initialise again
                a = 100; // reassign the origin ref variable to some other value
            System.out.println(a);

            

Reported by PMD.

lectures/6-conditions-loops/switch/src/com/kunal/NestedSwitch.java
21 issues
System.out.println is used
Design

Line: 13

              
        switch (empID) {
            case 1:
                System.out.println("Kunal Kushwaha");
                break;
            case 2:
                System.out.println("Rahul Rana");
                break;
            case 3:

            

Reported by PMD.

System.out.println is used
Design

Line: 16

                              System.out.println("Kunal Kushwaha");
                break;
            case 2:
                System.out.println("Rahul Rana");
                break;
            case 3:
                System.out.println("Emp Number 3");
                switch (department) {
                    case "IT":

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                              System.out.println("Rahul Rana");
                break;
            case 3:
                System.out.println("Emp Number 3");
                switch (department) {
                    case "IT":
                        System.out.println("IT Department");
                        break;
                    case "Management":

            

Reported by PMD.

System.out.println is used
Design

Line: 22

                              System.out.println("Emp Number 3");
                switch (department) {
                    case "IT":
                        System.out.println("IT Department");
                        break;
                    case "Management":
                        System.out.println("Management Department");
                        break;
                    default:

            

Reported by PMD.

System.out.println is used
Design

Line: 25

                                      System.out.println("IT Department");
                        break;
                    case "Management":
                        System.out.println("Management Department");
                        break;
                    default:
                        System.out.println("No department entered");
                }
                break;

            

Reported by PMD.

System.out.println is used
Design

Line: 28

                                      System.out.println("Management Department");
                        break;
                    default:
                        System.out.println("No department entered");
                }
                break;
            default:
                System.out.println("Enter correct EmpID");
        }

            

Reported by PMD.

System.out.println is used
Design

Line: 32

                              }
                break;
            default:
                System.out.println("Enter correct EmpID");
        }

        // better way to write
        switch (empID) {
            case 1 -> System.out.println("Kunal Kushwaha");

            

Reported by PMD.

System.out.println is used
Design

Line: 37

              
        // better way to write
        switch (empID) {
            case 1 -> System.out.println("Kunal Kushwaha");
            case 2 -> System.out.println("Rahul Rana");
            case 3 -> {
                System.out.println("Emp Number 3");
                switch (department) {
                    case "IT" -> System.out.println("IT Department");

            

Reported by PMD.

System.out.println is used
Design

Line: 38

                      // better way to write
        switch (empID) {
            case 1 -> System.out.println("Kunal Kushwaha");
            case 2 -> System.out.println("Rahul Rana");
            case 3 -> {
                System.out.println("Emp Number 3");
                switch (department) {
                    case "IT" -> System.out.println("IT Department");
                    case "Management" -> System.out.println("Management Department");

            

Reported by PMD.

System.out.println is used
Design

Line: 40

                          case 1 -> System.out.println("Kunal Kushwaha");
            case 2 -> System.out.println("Rahul Rana");
            case 3 -> {
                System.out.println("Emp Number 3");
                switch (department) {
                    case "IT" -> System.out.println("IT Department");
                    case "Management" -> System.out.println("Management Department");
                    default -> System.out.println("No department entered");
                }

            

Reported by PMD.

lectures/5-first-java-program/first-idea-program/src/com/kunal/Primitives.java
15 issues
System.out.println is used
Design

Line: 15

                      float c = 30.6f;
        c++;
//        c = (int)(c) + 1;
        System.out.println(c);
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              package com.kunal;

public class Primitives {
    public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;

            

Reported by PMD.

Avoid unused local variables such as 'rollno'.
Design

Line: 5

              
public class Primitives {
    public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

            

Reported by PMD.

Avoid unused local variables such as 'letter'.
Design

Line: 6

              public class Primitives {
    public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;


            

Reported by PMD.

Avoid unused local variables such as 'marks'.
Design

Line: 7

                  public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

        float c = 30.6f;

            

Reported by PMD.

Avoid unused local variables such as 'largeDecimalNumbers'.
Design

Line: 8

                      int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

        float c = 30.6f;
        c++;

            

Reported by PMD.

Avoid unused local variables such as 'largeInteger'.
Design

Line: 9

                      char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

        float c = 30.6f;
        c++;
//        c = (int)(c) + 1;

            

Reported by PMD.

Avoid unused local variables such as 'check'.
Design

Line: 10

                      float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

        float c = 30.6f;
        c++;
//        c = (int)(c) + 1;
        System.out.println(c);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'rollno' (lines '5'-'16').
Error

Line: 5

              
public class Primitives {
    public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'letter' (lines '6'-'16').
Error

Line: 6

              public class Primitives {
    public static void main(String[] args) {
        int rollno = 64;
        char letter = 'r';
        float marks = 98.67f;
        double largeDecimalNumbers = 4567654.4567;
        long largeInteger = 34567834567876543L;
        boolean check = false;


            

Reported by PMD.

lectures/8-arrays/code/src/com/kunal/Main.java
14 issues
System.out.println is used
Design

Line: 30

              //        System.out.println(ros[1]);

        String[] arr = new String[4];
        System.out.println(arr[0]);

//        for (String element : arr) {
//            System.out.println(element);
//        }


            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              package com.kunal;

public class Main {

    public static void main(String[] args) {
        // Q: store a roll number
        int a = 19;

        // Q: store a person's name

            

Reported by PMD.

Avoid unused local variables such as 'a'.
Design

Line: 7

              
    public static void main(String[] args) {
        // Q: store a roll number
        int a = 19;

        // Q: store a person's name
        String name = "Kunal Kushwaha";

        // Q: store 5 roll numbers

            

Reported by PMD.

Avoid unused local variables such as 'name'.
Design

Line: 10

                      int a = 19;

        // Q: store a person's name
        String name = "Kunal Kushwaha";

        // Q: store 5 roll numbers
        int rno1 = 23;
        int rno2 = 55;
        int rno3 = 18;

            

Reported by PMD.

Avoid unused local variables such as 'rno1'.
Design

Line: 13

                      String name = "Kunal Kushwaha";

        // Q: store 5 roll numbers
        int rno1 = 23;
        int rno2 = 55;
        int rno3 = 18;

        // syntax
        // datatype[] variable_name = new datatype[size];

            

Reported by PMD.

Avoid unused local variables such as 'rno2'.
Design

Line: 14

              
        // Q: store 5 roll numbers
        int rno1 = 23;
        int rno2 = 55;
        int rno3 = 18;

        // syntax
        // datatype[] variable_name = new datatype[size];
        // store 5 roll numbers:

            

Reported by PMD.

Avoid unused local variables such as 'rno3'.
Design

Line: 15

                      // Q: store 5 roll numbers
        int rno1 = 23;
        int rno2 = 55;
        int rno3 = 18;

        // syntax
        // datatype[] variable_name = new datatype[size];
        // store 5 roll numbers:
//        int[] rnos = new int[5];

            

Reported by PMD.

The value assigned to variable 'ros' is never used
Design

Line: 25

              //        int[] rnos2 = {23, 12, 45, 32, 15};

        int[] ros; // declaration of array. ros is getting defined in the stack
        ros = new int[5]; // initialisation: actually here object is being created in the memory (heap)

//        System.out.println(ros[1]);

        String[] arr = new String[4];
        System.out.println(arr[0]);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'a' (lines '7'-'36').
Error

Line: 7

              
    public static void main(String[] args) {
        // Q: store a roll number
        int a = 19;

        // Q: store a person's name
        String name = "Kunal Kushwaha";

        // Q: store 5 roll numbers

            

Reported by PMD.

Found 'DU'-anomaly for variable 'name' (lines '10'-'36').
Error

Line: 10

                      int a = 19;

        // Q: store a person's name
        String name = "Kunal Kushwaha";

        // Q: store 5 roll numbers
        int rno1 = 23;
        int rno2 = 55;
        int rno3 = 18;

            

Reported by PMD.

lectures/8-arrays/code/src/com/kunal/Input.java
11 issues
System.out.println is used
Design

Line: 18

                      arr[3] = 543;
        arr[4] = 3;
        // [23, 45, 233, 543, 3]
        System.out.println(arr[3]);

        // input using for loops
        for (int i = 0; i < arr.length; i++) {
            arr[i] = in.nextInt();
        }

            

Reported by PMD.

System.out.println is used
Design

Line: 43

                          str[i] = in.next();
        }

        System.out.println(Arrays.toString(str));

        // modify
        str[1] = "kunal";

        System.out.println(Arrays.toString(str));

            

Reported by PMD.

System.out.println is used
Design

Line: 48

                      // modify
        str[1] = "kunal";

        System.out.println(Arrays.toString(str));
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 6

              import java.util.Arrays;
import java.util.Scanner;

public class Input {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        // array of primitives
        int[] arr = new int[5];

            

Reported by PMD.

Ensure that resources like this Scanner object are closed after use
Error

Line: 8

              
public class Input {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        // array of primitives
        int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'in' (lines '8'-'49').
Error

Line: 8

              
public class Input {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        // array of primitives
        int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'arr' (lines '11'-'12').
Error

Line: 11

                      Scanner in = new Scanner(System.in);

        // array of primitives
        int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;
        arr[2] = 233;
        arr[3] = 543;
        arr[4] = 3;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'arr' (lines '12'-'13').
Error

Line: 12

              
        // array of primitives
        int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;
        arr[2] = 233;
        arr[3] = 543;
        arr[4] = 3;
        // [23, 45, 233, 543, 3]

            

Reported by PMD.

Found 'DD'-anomaly for variable 'arr' (lines '13'-'14').
Error

Line: 13

                      // array of primitives
        int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;
        arr[2] = 233;
        arr[3] = 543;
        arr[4] = 3;
        // [23, 45, 233, 543, 3]
        System.out.println(arr[3]);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'arr' (lines '14'-'15').
Error

Line: 14

                      int[] arr = new int[5];
        arr[0] = 23;
        arr[1] = 45;
        arr[2] = 233;
        arr[3] = 543;
        arr[4] = 3;
        // [23, 45, 233, 543, 3]
        System.out.println(arr[3]);


            

Reported by PMD.

lectures/9-linear search/code/src/com/kunal/EvenDigits.java
11 issues
System.out.println is used
Design

Line: 8

                      int[] nums = {12,345,2,6,7896};
//        System.out.println(findNumbers(nums));

        System.out.println(digits2(-345678));
    }
    static int findNumbers(int[] nums) {
        int count = 0;
        for(int num : nums) {
            if (even(num)) {

            

Reported by PMD.

Avoid reassigning parameters such as 'num'
Design

Line: 32

                      return numberOfDigits % 2 == 0;
    }

    static int digits2(int num) {
        if (num < 0) {
            num = num * -1;
        }
        return (int)(Math.log10(num)) + 1;
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'num'
Design

Line: 40

                  }

    // count number of digits in a number
    static int digits(int num) {

        if (num < 0) {
            num = num * -1;
        }


            

Reported by PMD.

Avoid reassigning parameters such as 'num'
Design

Line: 40

                  }

    // count number of digits in a number
    static int digits(int num) {

        if (num < 0) {
            num = num * -1;
        }


            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              package com.kunal;
// https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
public class EvenDigits {
    public static void main(String[] args) {
        int[] nums = {12,345,2,6,7896};
//        System.out.println(findNumbers(nums));

        System.out.println(digits2(-345678));
    }

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 10

              
        System.out.println(digits2(-345678));
    }
    static int findNumbers(int[] nums) {
        int count = 0;
        for(int num : nums) {
            if (even(num)) {
                count++;
            }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'nums' (lines '5'-'9').
Error

Line: 5

              // https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
public class EvenDigits {
    public static void main(String[] args) {
        int[] nums = {12,345,2,6,7896};
//        System.out.println(findNumbers(nums));

        System.out.println(digits2(-345678));
    }
    static int findNumbers(int[] nums) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '11'-'14').
Error

Line: 11

                      System.out.println(digits2(-345678));
    }
    static int findNumbers(int[] nums) {
        int count = 0;
        for(int num : nums) {
            if (even(num)) {
                count++;
            }
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '14'-'14').
Error

Line: 14

                      int count = 0;
        for(int num : nums) {
            if (even(num)) {
                count++;
            }
        }
        return count;
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '50'-'52').
Error

Line: 50

                          return 1;
        }

        int count = 0;
        while (num > 0) {
            count++;
            num = num / 10; // num /= 10
        }


            

Reported by PMD.

lectures/7-methods/code/src/com/kunal/Swap.java
10 issues
System.out.println is used
Design

Line: 15

              
        swap(a, b);

        System.out.println(a + " " + b);

        String name = "Kunal Kushwaha";
        changeName(name);
        System.out.println(name);
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 19

              
        String name = "Kunal Kushwaha";
        changeName(name);
        System.out.println(name);
    }

    static void changeName(String naam) {
        naam = "Rahul Rana"; // creating a new object
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'naam'
Design

Line: 22

                      System.out.println(name);
    }

    static void changeName(String naam) {
        naam = "Rahul Rana"; // creating a new object
    }

    static void swap(int num1, int num2) {
        int temp = num1;

            

Reported by PMD.

Avoid reassigning parameters such as 'num2'
Design

Line: 26

                      naam = "Rahul Rana"; // creating a new object
    }

    static void swap(int num1, int num2) {
        int temp = num1;
        num1 = num2;
        num2 = temp;
        // this change will only be valid in this function scope only.
    }

            

Reported by PMD.

Avoid reassigning parameters such as 'num1'
Design

Line: 26

                      naam = "Rahul Rana"; // creating a new object
    }

    static void swap(int num1, int num2) {
        int temp = num1;
        num1 = num2;
        num2 = temp;
        // this change will only be valid in this function scope only.
    }

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              package com.kunal;

public class Swap {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;

        // swap numbers code
//        int temp = a;

            

Reported by PMD.

The initial value of parameter 'naam' is never used (overwritten on line 23)
Design

Line: 22

                      System.out.println(name);
    }

    static void changeName(String naam) {
        naam = "Rahul Rana"; // creating a new object
    }

    static void swap(int num1, int num2) {
        int temp = num1;

            

Reported by PMD.

The value assigned to variable 'naam' is never used
Design

Line: 23

                  }

    static void changeName(String naam) {
        naam = "Rahul Rana"; // creating a new object
    }

    static void swap(int num1, int num2) {
        int temp = num1;
        num1 = num2;

            

Reported by PMD.

The value assigned to variable 'num1' is never used
Design

Line: 28

              
    static void swap(int num1, int num2) {
        int temp = num1;
        num1 = num2;
        num2 = temp;
        // this change will only be valid in this function scope only.
    }
}

            

Reported by PMD.

The value assigned to variable 'num2' is never used
Design

Line: 29

                  static void swap(int num1, int num2) {
        int temp = num1;
        num1 = num2;
        num2 = temp;
        // this change will only be valid in this function scope only.
    }
}

            

Reported by PMD.

lectures/5-first-java-program/first-idea-program/src/com/kunal/TypeCasting.java
9 issues
Do not use the short type
Performance

Line: 37

              
        byte b = 42;
        char c = 'a';
        short s = 1024;
        int i = 50000;
        float f = 5.67f;
        double d = 0.1234;
        double result = (f * b) + (i / c) - (d * s);
        // float + int - double = double

            

Reported by PMD.

System.out.println is used
Design

Line: 43

                      double d = 0.1234;
        double result = (f * b) + (i / c) - (d * s);
        // float + int - double = double
        System.out.println((f * b) + " " + (i / c) + " " + (d * s));
        System.out.println(result);
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 44

                      double result = (f * b) + (i / c) - (d * s);
        // float + int - double = double
        System.out.println((f * b) + " " + (i / c) + " " + (d * s));
        System.out.println(result);
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 5

              
import java.util.Scanner;

public class TypeCasting {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
//        float num = input.nextFloat();
//        int num = input.nextInt();
//        System.out.println(num);

            

Reported by PMD.

Ensure that resources like this Scanner object are closed after use
Error

Line: 7

              
public class TypeCasting {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
//        float num = input.nextFloat();
//        int num = input.nextInt();
//        System.out.println(num);

        // type casting

            

Reported by PMD.

Avoid unused local variables such as 'input'.
Design

Line: 7

              
public class TypeCasting {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
//        float num = input.nextFloat();
//        int num = input.nextInt();
//        System.out.println(num);

        // type casting

            

Reported by PMD.

Avoid unused local variables such as 'num'.
Design

Line: 13

              //        System.out.println(num);

        // type casting
        int num = (int)(67.56f);
//        System.out.println(num);

        // automatic type promotion in expressions
//        int a = 257;
//        byte b = (byte)(a); // 257 % 256 = 1

            

Reported by PMD.

Found 'DU'-anomaly for variable 'input' (lines '7'-'45').
Error

Line: 7

              
public class TypeCasting {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
//        float num = input.nextFloat();
//        int num = input.nextInt();
//        System.out.println(num);

        // type casting

            

Reported by PMD.

Found 'DU'-anomaly for variable 'num' (lines '13'-'45').
Error

Line: 13

              //        System.out.println(num);

        // type casting
        int num = (int)(67.56f);
//        System.out.println(num);

        // automatic type promotion in expressions
//        int a = 257;
//        byte b = (byte)(a); // 257 % 256 = 1

            

Reported by PMD.