Skip to content

Commit 90b47cb

Browse files
committed
updated garbage.java
1 parent 0bee9b7 commit 90b47cb

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

Java_Exp_4/Garbage.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import java.util.Scanner;
2-
public class Garbage{
32

4-
public static void main(String args[]) {
5-
3+
public class Garbage{
4+
5+
public static void main(String args[]) {
66
Student obj=new Student();
77
obj.getDetails();
88
obj.showDetails();
@@ -14,27 +14,30 @@ public static void main(String args[]) {
1414

1515
class Student {
1616
Scanner sc = new Scanner(System.in);
17-
17+
1818
String name,number;
1919
int rollno;
2020

2121
void getDetails() {
22-
System.out.printf("Enter the Name of Student : ");
22+
System.out.println("Enter the Name of Student : ");
2323
name = sc.next();
24-
System.out.printf("Enter the Roll No : ");
24+
System.out.println("Enter the Roll No : ");
2525
rollno = sc.nextInt();
26-
System.out.printf("Enter Phone Number : ");
26+
System.out.println("Enter Phone Number : ");
2727
number = sc.next();
2828

2929
}
3030

3131
void showDetails() {
32-
System.out.printf("\nThe Name of Student is %s \n",name);
33-
System.out.printf("Enter the Roll No : %d \n",rollno);
34-
System.out.printf("Enter Phone Number : %s \n",number);
32+
33+
System.out.println("\n Details\n");
34+
System.out.println("The Name of Student is " +name);
35+
System.out.println("Roll No is " +rollno);
36+
System.out.println("Phone Number is " +number);
37+
3538
}
3639

3740
protected void finalize() {
38-
System.out.println("\nGarbage of Object Collected");
41+
System.out.println("\nGarbage of Object Collected");
3942
}
4043
}

Java_Exp_4/README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ Hexagon has 6 sides.
6262
[Garbage.java](https://github.com/akkupy/JavaS3/blob/master/Java_Exp_4/Garbage.java) - Write a Java program to demonstrate the use of garbage collector.
6363

6464
```
65-
Enter the Name of Student : Akash
66-
Enter the Roll No : 12
67-
Enter Phone Number : 1231234
65+
Enter the Name of Student :
66+
Akash
67+
Enter the Roll No :
68+
09
69+
Enter Phone Number :
70+
123456
71+
72+
Details
6873
6974
The Name of Student is Akash
70-
Enter the Roll No : 12
71-
Enter Phone Number : 1231234
75+
Roll No is 9
76+
Phone Number is 123456
7277
7378
Garbage of Object Collected
7479
```

0 commit comments

Comments
 (0)