Where to use this and what does this mean sc.close();

if we are creating a simple code then we use sc.close in end of the main statement but when we are using a class or method then where to use sc.close