-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGarbage.java
More file actions
43 lines (32 loc) · 971 Bytes
/
Copy pathGarbage.java
File metadata and controls
43 lines (32 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.Scanner;
public class Garbage{
public static void main(String args[]) {
Student obj=new Student();
obj.getDetails();
obj.showDetails();
obj=null;
System.gc();
}
}
class Student {
Scanner sc = new Scanner(System.in);
String name,number;
int rollno;
void getDetails() {
System.out.println("Enter the Name of Student : ");
name = sc.next();
System.out.println("Enter the Roll No : ");
rollno = sc.nextInt();
System.out.println("Enter Phone Number : ");
number = sc.next();
}
void showDetails() {
System.out.println("\n Details\n");
System.out.println("The Name of Student is " +name);
System.out.println("Roll No is " +rollno);
System.out.println("Phone Number is " +number);
}
protected void finalize() {
System.out.println("\nGarbage of Object Collected");
}
}