-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstruct.java
More file actions
39 lines (31 loc) · 730 Bytes
/
Copy pathconstruct.java
File metadata and controls
39 lines (31 loc) · 730 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
class Student
{
String name;
int age;
static int count = 0;
Student(String n, int a)
{
name = n;
age = a;
System.out.println("No. of students: " + count++);
}
void display()
{
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("\n\n");
}
}
public class construct
{
public static void main(String args[])
{
Student P1 = new Student("Rohan", 19);
P1.display();
Student P2 = new Student("Amit", 21);
P2.display();
Student P3 = new Student("Shantanu", 20);
P3.display();
System.out.println("Total students = " + Student.count);
}
}