funtion of close() method?
I have below codes everthing is working fine, however I do not understant the reason of using in.close(); method at the end, program works fine without of in.close(); also, but what is the purpose of using it?
public class SongTime
public static void main(String args)
Scanner in = new Scanner(System.in);
//Prompt for input
System.out.println("Enter the price , the time of the song in second,");
System.out.println(" and the name of the song, all seperated blanks: ");
price = in.nextDouble();
seconds = in.nextInt();
name = in.nextLine();
//Output song name, cost, and time in minutes and seconds
System.out.println(name + "cost$" + price + " and is " + seconds/60 + " minute(s), and " +
seconds%60 + " second(s) long.");
double costPerMinute = price/((double)seconds / 60.0);
System.out.println("Cost per minute is $ "+ costPerMinute);