Created
August 17, 2020 11:22
-
-
Save faramarzaf/b0d913ab80d8348badcf538267c296c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student{ | |
private String name; | |
private int roll_No; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getRoll_no() { | |
return roll_No; | |
} | |
public void setRoll_no(int roll_no) { | |
this.roll_No = roll_no; | |
} | |
} | |
// | |
public class Test{ | |
public static void main(String[] args){ | |
Student s1 = new Student(); | |
Class c1 = s1.getClass(); | |
System.out.println(c1.getName()); | |
گرفتن همه ی متدهای موجود | |
Method m[] = c1.getDeclaredMethods(); | |
for (Method method : m) | |
System.out.println(method.getName()); | |
گرفتن همه متغیرها | |
Field f[] = c1.getDeclaredFields(); | |
for (Field field : f) | |
System.out.println(field.getName()); | |
} | |
} | |
خروجی: | |
Student | |
getName | |
setName | |
getRoll_no | |
setRoll_no | |
name | |
roll_No |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment