Skip to content

Commit 106de81

Browse files
author
uodut
committed
类的命名不规范问题
1 parent 799741c commit 106de81

File tree

12 files changed

+72
-72
lines changed

12 files changed

+72
-72
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package BasicDao;
22

3-
public class Person_HashSet {
4-
public Person_HashSet(){
3+
public class PersonHashSet {
4+
public PersonHashSet(){
55
}
6-
public Person_HashSet(int age,String name){
6+
public PersonHashSet(int age,String name){
77
this.age = age;
88
this.name = name;
99
}
@@ -37,7 +37,7 @@ public boolean equals(Object obj) {
3737
return false;
3838
if (getClass() != obj.getClass())
3939
return false;
40-
Person_HashSet other = (Person_HashSet) obj;
40+
PersonHashSet other = (PersonHashSet) obj;
4141
if (age != other.age)
4242
return false;
4343
if (name == null) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package BasicDao;
22

3-
public class Person_Reflect {
3+
public class PersonReflect {
44
private int age;
55
int score;
66
public String name;
@@ -39,7 +39,7 @@ public void setName(String name) {
3939
}
4040

4141

42-
public Person_Reflect(int age, int score, String name) {
42+
public PersonReflect(int age, int score, String name) {
4343
this.age = age;
4444
this.score = score;
4545
this.name = name;
@@ -54,6 +54,6 @@ private boolean isMarray(){
5454
}
5555

5656

57-
public Person_Reflect(){
57+
public PersonReflect(){
5858
}
5959
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package BasicDao;
22

3-
public class Person_Reflect_son extends Person_Reflect {
3+
public class PersonReflect_son extends PersonReflect {
44

55
private String address;
66
public int members;
@@ -21,13 +21,13 @@ public void setMembers(int members) {
2121
this.members = members;
2222
}
2323

24-
public Person_Reflect_son(int age, int score, String name) {
24+
public PersonReflect_son(int age, int score, String name) {
2525
super(age, score, name);
2626
// TODO Auto-generated constructor stub
2727

2828
}
2929

30-
public Person_Reflect_son() {
30+
public PersonReflect_son() {
3131
super();
3232
}
3333

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package BasicDao;
22

3-
public class Person_TreeMap {
3+
public class PersonTreeMap {
44
private int score;
55
private String name;
66
public int getScore() {
@@ -15,7 +15,7 @@ public String getName() {
1515
public void setName(String name) {
1616
this.name = name;
1717
}
18-
public Person_TreeMap(int score, String name) {
18+
public PersonTreeMap(int score, String name) {
1919
this.score = score;
2020
this.name = name;
2121
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package BasicDao;
22

3-
public class Person_TreeSet implements Comparable<Object>{
3+
public class PersonTreeSet implements Comparable<Object>{
44
private int age;
55
private String name;
66
public int getAge() {
@@ -15,13 +15,13 @@ public String getName() {
1515
public void setName(String name) {
1616
this.name = name;
1717
}
18-
public Person_TreeSet(int age, String name) {
18+
public PersonTreeSet(int age, String name) {
1919
this.age = age;
2020
this.name = name;
2121
}
2222
@Override
2323
public int compareTo(Object o) {
24-
Person_TreeSet pt = (Person_TreeSet)o;
24+
PersonTreeSet pt = (PersonTreeSet)o;
2525
int ageCompareResult = this.age - pt.getAge();
2626
int nameCompare = this.name.compareTo(pt.getName());
2727
//比较规则:年龄相同按照姓名顺序排序,年龄不同按照年龄大小排序
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package BasicDao;
22

3-
public class Person_TreeSet2{
3+
public class PersonTreeSet2{
44
private int age;
55
private String name;
66
public int getAge() {
@@ -15,7 +15,7 @@ public String getName() {
1515
public void setName(String name) {
1616
this.name = name;
1717
}
18-
public Person_TreeSet2(int age, String name) {
18+
public PersonTreeSet2(int age, String name) {
1919
this.age = age;
2020
this.name = name;
2121
}

src/DesignMode/DynamicProxy/InvocationHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Object invoke(Object proxy, Method method, Object[] args)
2020
throws Throwable {
2121
System.out.println("你将调用invoke方法,当前方法名为" +method.getName() );
2222
//method.invoke(bird,null);
23-
method.invoke(bird, null);//调用bird的method方法
23+
method.invoke(bird, args);//调用bird的method方法
2424
System.out.println(method.getName()+"已经调用完毕");
2525
return null;
2626
}

src/Reflect/ReflectDemo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import java.lang.reflect.Field;
55
import java.lang.reflect.Method;
66
import java.lang.reflect.Modifier;
7-
import BasicDao.Person_Reflect;
8-
import BasicDao.Person_Reflect_son;
7+
import BasicDao.PersonReflect;
8+
import BasicDao.PersonReflect_son;
99

1010
/*
1111
1、Java反射的概念
@@ -41,9 +41,9 @@ public class
4141
ReflectDemo {
4242
public static void main(String[] args) throws Exception {
4343
// 获取一个类的Class对象
44-
Class<?> c1 = Person_Reflect.class;
44+
Class<?> c1 = PersonReflect.class;
4545
Class<?> c2 = Class.forName("BasicDao.Person_Reflect");
46-
Class<?> c3 = new Person_Reflect_son().getClass();
46+
Class<?> c3 = new PersonReflect_son().getClass();
4747
// 获取指定的包名
4848
String packageName1 = c1.getPackage().getName();// out->BasicDao
4949
String packageName2 = c2.getPackage().getName();// out->BasicDao
@@ -128,7 +128,7 @@ public static void main(String[] args) throws Exception {
128128
/*-----------------------------------------------------------------------------------------*/
129129
//方法使用:给类的属性赋值
130130
static void executeMethod(Class<?> c) throws Exception{
131-
Person_Reflect pr = (Person_Reflect)c.newInstance();
131+
PersonReflect pr = (PersonReflect)c.newInstance();
132132
Method method = c.getDeclaredMethod("setName", String.class);
133133
method.invoke(pr, "tudou");
134134
System.out.println(pr.getName());

src/util/Collection/Map/TreeMapDemo.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Set;
66
import java.util.TreeMap;
77

8-
import BasicDao.Person_TreeMap;
8+
import BasicDao.PersonTreeMap;
99

1010
/**
1111
* 底层实现为红黑树(一种自平衡的二叉查找树)
@@ -88,10 +88,10 @@ Collection<V> values()
8888
public class TreeMapDemo {
8989
public static void main(String[] args) {
9090
//排序规则
91-
TreeMap<Person_TreeMap, String> tm = new TreeMap<Person_TreeMap, String>(
92-
new Comparator<Person_TreeMap>() {
91+
TreeMap<PersonTreeMap, String> tm = new TreeMap<PersonTreeMap, String>(
92+
new Comparator<PersonTreeMap>() {
9393
@Override
94-
public int compare(Person_TreeMap pt1, Person_TreeMap pt2) {
94+
public int compare(PersonTreeMap pt1, PersonTreeMap pt2) {
9595
int ageCompareResult = pt1.getScore() - pt2.getScore();
9696
int nameCompareResult = pt1.getName().compareTo(
9797
pt2.getName());
@@ -101,10 +101,10 @@ public int compare(Person_TreeMap pt1, Person_TreeMap pt2) {
101101
return result;
102102
}
103103
});
104-
tm.put(new Person_TreeMap(95,"tudou"),"第一名");
105-
tm.put(new Person_TreeMap(92,"tiny"),"第二名");
106-
tm.put(new Person_TreeMap(90,"monica"),"第三名");
107-
tm.put(new Person_TreeMap(59,"zack"),"第四名");
104+
tm.put(new PersonTreeMap(95,"tudou"),"第一名");
105+
tm.put(new PersonTreeMap(92,"tiny"),"第二名");
106+
tm.put(new PersonTreeMap(90,"monica"),"第三名");
107+
tm.put(new PersonTreeMap(59,"zack"),"第四名");
108108

109109
//第一种方法
110110
System.out.println("---------第一种方法-----------");
@@ -113,21 +113,21 @@ public int compare(Person_TreeMap pt1, Person_TreeMap pt2) {
113113
display2(tm);
114114
}
115115
//根据key找value,遍历
116-
static void display1(TreeMap<Person_TreeMap,String> tm){
117-
Set<Person_TreeMap> set= tm.keySet();
116+
static void display1(TreeMap<PersonTreeMap,String> tm){
117+
Set<PersonTreeMap> set= tm.keySet();
118118
System.out.println("姓名" + '\t' + "分数" + '\t' + "排名");
119-
for(Person_TreeMap pt:set){
119+
for(PersonTreeMap pt:set){
120120
System.out.println(pt.getName() + '\t' + pt.getScore() + '\t' + tm.get(pt) );
121121
}
122122
}
123123
//根据视图遍历
124-
static void display2(TreeMap<Person_TreeMap,String> tm){
125-
Set<Entry<Person_TreeMap, String>>set = tm.entrySet();
124+
static void display2(TreeMap<PersonTreeMap,String> tm){
125+
Set<Entry<PersonTreeMap, String>>set = tm.entrySet();
126126
String name = null;
127127
Integer score = null;
128128
String level = null;
129129
System.out.println("姓名" + '\t' + "分数" + '\t' + "排名");
130-
for(Entry<Person_TreeMap,String> s:set){
130+
for(Entry<PersonTreeMap,String> s:set){
131131
name = s.getKey().getName();
132132
score = s.getKey().getScore();
133133
level = s.getValue();

src/util/Collection/set/HashSetDemo.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.HashSet;
44
import java.util.Iterator;
55

6-
import BasicDao.Person_HashSet;
6+
import BasicDao.PersonHashSet;
77
/**
88
*
99
* @author UODUT
@@ -20,13 +20,13 @@
2020
相等,比较equals()是否相等。如果二者都相等,则不能添加。
2121
*/
2222
public class HashSetDemo {
23-
static HashSet<Person_HashSet> hashSet = new HashSet<Person_HashSet>();
23+
static HashSet<PersonHashSet> hashSet = new HashSet<PersonHashSet>();
2424
public static void main(String[] args) {
25-
Person_HashSet person1 = new Person_HashSet(20,"zhang");
26-
Person_HashSet person5 = new Person_HashSet(20,"zhang");
27-
Person_HashSet person2 = new Person_HashSet(20,"wang");
28-
Person_HashSet person3 = new Person_HashSet(22,"li");
29-
Person_HashSet person4 = new Person_HashSet(20,"li");
25+
PersonHashSet person1 = new PersonHashSet(20,"zhang");
26+
PersonHashSet person5 = new PersonHashSet(20,"zhang");
27+
PersonHashSet person2 = new PersonHashSet(20,"wang");
28+
PersonHashSet person3 = new PersonHashSet(22,"li");
29+
PersonHashSet person4 = new PersonHashSet(20,"li");
3030
hashSet.add(person1);
3131
hashSet.add(person2);
3232
hashSet.add(person3);
@@ -41,16 +41,16 @@ public static void main(String[] args) {
4141
System.out.println(hashSet.size());
4242

4343
}
44-
static void display(HashSet<Person_HashSet> hashSet ){
45-
Iterator<Person_HashSet> it = hashSet.iterator();
44+
static void display(HashSet<PersonHashSet> hashSet ){
45+
Iterator<PersonHashSet> it = hashSet.iterator();
4646
System.out.println("姓名" + '\t' + "年龄");
4747
while(it.hasNext()){
4848
System.out.println(it.next().getName()+'\t' + it.next().getAge());
4949
}
5050
}
51-
static void display2(HashSet<Person_HashSet> hashSet){
51+
static void display2(HashSet<PersonHashSet> hashSet){
5252
System.out.println("姓名" + '\t' + "年龄");
53-
for(Person_HashSet p:hashSet){
53+
for(PersonHashSet p:hashSet){
5454
System.out.println(p.getName()+'\t' + p.getAge());
5555
}
5656
}

0 commit comments

Comments
 (0)