Closing scanners.

This commit is contained in:
Hassan
2020-01-28 18:34:52 +02:00
parent 4f45c5a479
commit a1f59c38b1
27 changed files with 29 additions and 4 deletions

View File

@ -80,5 +80,6 @@ public class Dijkshtra {
System.out.print("-1" + " ");
}
}
in.close();
}
}

View File

@ -44,5 +44,6 @@ public class InsertDeleteInArray {
}
for (i = 0; i < size2 - 1; i++)
System.out.println(b[i]);
s.close();
}
}

View File

@ -29,6 +29,7 @@ public class LowestBasePalindrome {
}
System.out.println(n + " is a palindrome in base " + lowestBasePalindrome(n));
System.out.println(base2base(Integer.toString(n), 10, lowestBasePalindrome(n)));
in.close();
}
/**

View File

@ -162,5 +162,6 @@ public class PerlinNoise {
System.out.println();
}
in.close();
}
}

View File

@ -20,6 +20,7 @@ public class PowerOfTwoOrNot {
} else {
System.out.println("Number is not a power of two");
}
sc.close();
}
@ -32,5 +33,4 @@ public class PowerOfTwoOrNot {
public static boolean checkIfPowerOfTwoOrNot(int number) {
return number != 0 && ((number & (number - 1)) == 0);
}
}

View File

@ -13,6 +13,7 @@ public class ReturnSubsequence {
for (int i = 0; i < subsequence.length; i++) {
System.out.println(subsequence[i]);
}
s.close();
}
/**

View File

@ -14,6 +14,8 @@ public class RootPrecision {
// P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
int P = scn.nextInt();
System.out.println(squareRoot(N, P));
scn.close();
}
public static double squareRoot(int N, int P) {

View File

@ -67,6 +67,7 @@ class Schedule {
processes.add(p);
burstAll += p.burstTime;
}
in.close();
}

View File

@ -7,6 +7,7 @@ public class StackPostfixNotation {
Scanner scanner = new Scanner(System.in);
String post = scanner.nextLine(); // Takes input with spaces in between eg. "1 21 +"
System.out.println(postfixEvaluate(post));
scanner.close();
}
// Evaluates the given postfix expression string and returns the result.
@ -35,6 +36,7 @@ public class StackPostfixNotation {
// "+", "-", "*", "/"
}
}
tokens.close();
return s.pop();
}
}

View File

@ -82,6 +82,7 @@ public class TopKWords {
for (int i = 0; i < k; i++) {
System.out.println(list.get(list.size() - i - 1));
}
input.close();
}
}

View File

@ -22,5 +22,6 @@ class TowerOfHanoi {
Scanner scanner = new Scanner(System.in);
int numberOfDiscs = scanner.nextInt(); //input of number of discs on pole 1
shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); //Shift function called
scanner.close();
}
}