Fixing resource leaks

master
sgoudham 4 years ago
parent 0ed367c6eb
commit 1277fecc35
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -14,6 +14,7 @@ public class SimpleArrays {
values[currentSize] = in.nextInt();
currentSize++;
}
in.close();
//Find The Largest Value
double largest = values[0];

@ -25,6 +25,7 @@ public class UsingScanner {
double pricePerOunce = packPrice / packVolume;
System.out.printf("Price per ounce: %8.2f", pricePerOunce);
in.close();
}
}

@ -57,12 +57,11 @@ public class WorkingWithStrings {
System.out.println("The Last Letter Of The Name is " + last);
// Generating userID from strings entered
Scanner sc = new Scanner(System.in);
System.out.println("Please enter your first name: ");
String firstName = sc.next();
String firstName = in.next();
System.out.println("Please enter your last name: ");
String secondName = sc.next();
sc.close();
String secondName = in.next();
in.close();
LocalDateTime nowIsTheTime = LocalDateTime.now();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");

Loading…
Cancel
Save