The following issues were found

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

Line: 8

              //        fun(67);
//        fun("Kunal Kushwaha");
        int ans = sum(3, 4, 78);
        System.out.println(ans);
    }

    static int sum(int a, int b) {
        return a + b;
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 20

                  }

    static void fun(int a) {
        System.out.println("first one");
        System.out.println(a);
    }

    static void fun(String name) {
        System.out.println("Second one");

            

Reported by PMD.

System.out.println is used
Design

Line: 21

              
    static void fun(int a) {
        System.out.println("first one");
        System.out.println(a);
    }

    static void fun(String name) {
        System.out.println("Second one");
        System.out.println(name);

            

Reported by PMD.

System.out.println is used
Design

Line: 25

                  }

    static void fun(String name) {
        System.out.println("Second one");
        System.out.println(name);
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 26

              
    static void fun(String name) {
        System.out.println("Second one");
        System.out.println(name);
    }
}

            

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 Overloading {
    public static void main(String[] args) {
//        fun(67);
//        fun("Kunal Kushwaha");
        int ans = sum(3, 4, 78);
        System.out.println(ans);
    }

            

Reported by PMD.

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

Line: 23

              //        };

        int[][] arr = new int[3][3];
        System.out.println(arr.length); // no of rows
        // input

        for (int row = 0; row < arr.length; row++) {
            // for each col in every row
            for (int col = 0; col < arr[row].length; col++) {

            

Reported by PMD.

System.out.println is used
Design

Line: 48

              //        }

        for(int[] a : arr) {
            System.out.println(Arrays.toString(a));
        }
    }
}

            

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 MultiDimension {
    public static void main(String[] args) {
        /*
             1 2 3
             4 5 6
             7 8 9

            

Reported by PMD.

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

Line: 13

                           4 5 6
             7 8 9
        */
        Scanner in = new Scanner(System.in);
//        int[][] arr = new int[3][];

//        int[][] arr = {
//                {1, 2, 3}, // 0th index
//                {4, 5}, // 1st index

            

Reported by PMD.

Found 'DU'-anomaly for variable 'in' (lines '13'-'50').
Error

Line: 13

                           4 5 6
             7 8 9
        */
        Scanner in = new Scanner(System.in);
//        int[][] arr = new int[3][];

//        int[][] arr = {
//                {1, 2, 3}, // 0th index
//                {4, 5}, // 1st index

            

Reported by PMD.

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

Line: 34

              
        // get item at any index
        for (int i = 0; i < 5; i++) {
            System.out.println(list.get(i)); // pass index here, list[index] syntax will not work here
        }

        System.out.println(list);



            

Reported by PMD.

System.out.println is used
Design

Line: 37

                          System.out.println(list.get(i)); // pass index here, list[index] syntax will not work here
        }

        System.out.println(list);



    }
}

            

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.ArrayList;
import java.util.Scanner;

public class ArrayListExample {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Syntax
        ArrayList<Integer> list = new ArrayList<>(5);


            

Reported by PMD.

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

Line: 8

              
public class ArrayListExample {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Syntax
        ArrayList<Integer> list = new ArrayList<>(5);

//        list.add(67);
//        list.add(234);

            

Reported by PMD.

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

Line: 8

              
public class ArrayListExample {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // Syntax
        ArrayList<Integer> list = new ArrayList<>(5);

//        list.add(67);
//        list.add(234);

            

Reported by PMD.

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

Line: 15

                      };
        int target = 56;
        int[] ans = search(arr,target); // format of return value {row, col}
        System.out.println(Arrays.toString(ans));

        System.out.println(max(arr));

        System.out.println(Integer.MIN_VALUE);
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 17

                      int[] ans = search(arr,target); // format of return value {row, col}
        System.out.println(Arrays.toString(ans));

        System.out.println(max(arr));

        System.out.println(Integer.MIN_VALUE);
    }

    static int[] search(int[][] arr, int target) {

            

Reported by PMD.

System.out.println is used
Design

Line: 19

              
        System.out.println(max(arr));

        System.out.println(Integer.MIN_VALUE);
    }

    static int[] search(int[][] arr, int target) {
        for (int row = 0; row < arr.length; row++) {
            for (int col = 0; col < arr[row].length; col++) {

            

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.Arrays;

public class SearchIn2DArray {
    public static void main(String[] args) {
        int[][] arr = {
                {23, 4, 1},
                {18, 12, 3, 9},
                {78, 99, 34, 56},

            

Reported by PMD.

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

Line: 33

                      return new int[]{-1, -1};
    }

    static int max(int[][] arr) {
        int max = Integer.MIN_VALUE;
        for (int[] ints : arr) {
            for (int element : ints) {
                if (element > max) {
                    max = element;

            

Reported by PMD.

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

Line: 23

                          }
        }

        System.out.println(list);
    }
}

            

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.ArrayList;
import java.util.Scanner;

public class MultiAL {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<ArrayList<Integer>> list = new ArrayList<>();

        // initialisation

            

Reported by PMD.

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

Line: 8

              
public class MultiAL {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<ArrayList<Integer>> list = new ArrayList<>();

        // initialisation
        for (int i = 0; i < 3; i++) {
            list.add(new ArrayList<>());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 19

                      // add elements
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                list.get(i).add(in.nextInt());
            }
        }

        System.out.println(list);
    }

            

Reported by PMD.

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

Line: 8

              
public class MultiAL {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<ArrayList<Integer>> list = new ArrayList<>();

        // initialisation
        for (int i = 0; i < 3; i++) {
            list.add(new ArrayList<>());

            

Reported by PMD.

lectures/6-conditions-loops/code/src/com/kunal/Fibo.java
5 issues
System.out.println is used
Design

Line: 20

                          count++;
        }

        System.out.println(b);
    }
}

            

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 Fibo {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = 0;
        int b = 1;

            

Reported by PMD.

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

Line: 7

              
public class Fibo {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = 0;
        int b = 1;
        int count = 2;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'a' (lines '9'-'21').
Error

Line: 9

                  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = 0;
        int b = 1;
        int count = 2;

        while (count <= n) {
            int temp = b;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'a' (lines '16'-'21').
Error

Line: 16

                      while (count <= n) {
            int temp = b;
            b = b + a;
            a = temp;
            count++;
        }

        System.out.println(b);
    }

            

Reported by PMD.

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

Line: 11

                      char target = 'u';
//        System.out.println(search(name, target));

        System.out.println(Arrays.toString(name.toCharArray()));
    }


    static boolean search2(String str, char target) {
        if (str.length() == 0) {

            

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.Arrays;

public class SearchInStrings {
    public static void main(String[] args) {
        String name = "Kunal";
        char target = 'u';
//        System.out.println(search(name, target));


            

Reported by PMD.

Avoid unused local variables such as 'target'.
Design

Line: 8

              public class SearchInStrings {
    public static void main(String[] args) {
        String name = "Kunal";
        char target = 'u';
//        System.out.println(search(name, target));

        System.out.println(Arrays.toString(name.toCharArray()));
    }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 11

                      char target = 'u';
//        System.out.println(search(name, target));

        System.out.println(Arrays.toString(name.toCharArray()));
    }


    static boolean search2(String str, char target) {
        if (str.length() == 0) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'target' (lines '8'-'12').
Error

Line: 8

              public class SearchInStrings {
    public static void main(String[] args) {
        String name = "Kunal";
        char target = 'u';
//        System.out.println(search(name, target));

        System.out.println(Arrays.toString(name.toCharArray()));
    }


            

Reported by PMD.

lectures/6-conditions-loops/code/src/com/kunal/CountNums.java
5 issues
System.out.println is used
Design

Line: 16

                          n = n / 10; // n /= 10
        }

        System.out.println(count);
    }
}

            

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 CountNums {
    public static void main(String[] args) {
        int n = 45535;

        int count = 0;
        while (n > 0) {
            int rem = n % 10;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 10

                      int count = 0;
        while (n > 0) {
            int rem = n % 10;
            if (rem == 5) {
                count++;
            }
            n = n / 10; // n /= 10
        }


            

Reported by PMD.

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

Line: 7

                  public static void main(String[] args) {
        int n = 45535;

        int count = 0;
        while (n > 0) {
            int rem = n % 10;
            if (rem == 5) {
                count++;
            }

            

Reported by PMD.

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

Line: 11

                      while (n > 0) {
            int rem = n % 10;
            if (rem == 5) {
                count++;
            }
            n = n / 10; // n /= 10
        }

        System.out.println(count);

            

Reported by PMD.

lectures/6-conditions-loops/code/src/com/kunal/Loops.java
5 issues
System.out.println is used
Design

Line: 58

                       */
        int n = 1;
        do {
            System.out.println("Hello World");
        } while (n != 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: 5

              
import java.util.Scanner;

public class Loops {
    public static void main(String[] args) {

        /*
            Syntax of for loops:


            

Reported by PMD.

Avoid unused local variables such as 'in'.
Design

Line: 22

              //        }

        // print numbers from 1 to n
        Scanner in = new Scanner(System.in);
//        int n = in.nextInt();

//        for (int num = 1; num <= n; num++) {
////            System.out.print(num + " ");
//            System.out.println("Hello World");

            

Reported by PMD.

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

Line: 22

              //        }

        // print numbers from 1 to n
        Scanner in = new Scanner(System.in);
//        int n = in.nextInt();

//        for (int num = 1; num <= n; num++) {
////            System.out.print(num + " ");
//            System.out.println("Hello World");

            

Reported by PMD.

Found 'DU'-anomaly for variable 'in' (lines '22'-'61').
Error

Line: 22

              //        }

        // print numbers from 1 to n
        Scanner in = new Scanner(System.in);
//        int n = in.nextInt();

//        for (int num = 1; num <= n; num++) {
////            System.out.print(num + " ");
//            System.out.println("Hello World");

            

Reported by PMD.

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

Line: 8

              public class PassinginFunctions {
    public static void main(String[] args) {
        int[] nums = {3, 4, 5, 12};
        System.out.println(Arrays.toString(nums));
        change(nums);
        System.out.println(Arrays.toString(nums));
    }
    static void change(int[] arr) {
        arr[0] = 99;

            

Reported by PMD.

System.out.println is used
Design

Line: 10

                      int[] nums = {3, 4, 5, 12};
        System.out.println(Arrays.toString(nums));
        change(nums);
        System.out.println(Arrays.toString(nums));
    }
    static void change(int[] arr) {
        arr[0] = 99;
    }
}

            

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.Arrays;

public class PassinginFunctions {
    public static void main(String[] args) {
        int[] nums = {3, 4, 5, 12};
        System.out.println(Arrays.toString(nums));
        change(nums);
        System.out.println(Arrays.toString(nums));

            

Reported by PMD.

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

Line: 12

                      change(nums);
        System.out.println(Arrays.toString(nums));
    }
    static void change(int[] arr) {
        arr[0] = 99;
    }
}

            

Reported by PMD.