We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a4af6b8 commit 4028c18Copy full SHA for 4028c18
model/main_within_class.java
@@ -1 +1,16 @@
1
2
+//Java Program to illustrate how to define a class and fields
3
+//Defining a Student class.
4
+class Student{
5
+ //defining fields
6
+ int id;//field or data member or instance variable
7
+ String name;
8
+ //creating main method inside the Student class
9
+ public static void main(String args[]){
10
+ //Creating an object or instance
11
+ Student s1=new Student();//creating an object of Student
12
+ //Printing values of the object
13
+ System.out.println(s1.id);//accessing member through reference variable
14
+ System.out.println(s1.name);
15
+ }
16
+}
0 commit comments