-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent1
48 lines (38 loc) · 870 Bytes
/
Student1
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
44
45
46
47
48
public class Student1
{
private String stName;
private int stId;
static String collegeName;
static int counter = 0;
//Constructor
public Student1(String stName)
{
this.stName = stName;
this.stId = setStId();
}
//Method
public static int setStId()
{
counter++;
return counter;
}
//Static methods cannot have "this.cgeName"
public static void setCollegeName(String cgeName)
{
collegeName = cgeName;
}
public void getStudentInfo()
{
System.out.println("Name: " + this.stName);
System.out.println("ID: " + this.stId);
System.out.println("College name: " +collegeName + "\n");
}
public static void main(String[] args)
{
Student1.setCollegeName("Centennial College");
Student1 st1 = new Student1("Carlos Dutra");
Student1 st2 = new Student1("Jose Arthur");
st1.getStudentInfo();
st2.getStudentInfo();
}
}