Skip to content

Commit 57b7ef0

Browse files
committed
Merge branch 'master' of https://github.com/ChengPeng15/HHHH.git
2 parents 5340a3e + 965cfc7 commit 57b7ef0

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

Java/src/算法/charToString.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package 算法;
2+
3+
public class charToString {
4+
5+
public static void main(String[] args) {
6+
// char[]array={'1','2','3','4','5'};
7+
String str="Hello World";
8+
char[]array=str.toCharArray();
9+
System.out.println(new String(array));
10+
StringBuffer str1 = new StringBuffer();
11+
// public StringBuffer() {
12+
// super(16);
13+
// }
14+
//
15+
// public StringBuffer(int capacity) {
16+
// super(capacity);
17+
// }
18+
//
19+
// public StringBuffer(String str) {
20+
// super(str.length() + 16);
21+
// append(str);
22+
// }
23+
24+
}
25+
}

Java/src/继承/Soner.java

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package 继承;
2+
//final不能被重写 方法同名 返回类型相同 即使不写override也是重写
3+
class fathers {
4+
private void aa() {
5+
System.out.println("f----aa");
6+
}
7+
8+
final void aa1() {
9+
System.out.println("f----aa1");
10+
}
11+
}
12+
13+
public class Soner extends fathers {
14+
15+
void aa() {
16+
System.out.println("ssss----aa");
17+
18+
}
19+
20+
//这个跟父类final方法没关系
21+
22+
int aa1(int a) {
23+
System.out.println("int----aa");
24+
return 1;
25+
}
26+
public static void main(String[] args) {
27+
// TODO Auto-generated method stub
28+
29+
Soner s = new Soner();
30+
s.aa();
31+
s.aa1();
32+
s.aa1(1);//
33+
}
34+
35+
}

Java/src/继承/重载的坑.java Java/src/继承/重写的坑.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package 继承;
22

3-
class 重载父类{
3+
class 重写父类{
44
void a(){
55
System.out.println("父类a");
66
}
@@ -11,7 +11,7 @@ void b(){
1111
}
1212

1313

14-
class 重载子类 extends 重载父类{
14+
class 重写子类 extends 重写父类{
1515
void a(){
1616
System.out.println("子类a");
1717
}
@@ -23,9 +23,9 @@ void b(){
2323
}
2424
}
2525

26-
public class 重载的坑 {
26+
public class 重写的坑 {
2727
public static void main(String[] args) {
28-
重载父类 a = new 重载子类();
28+
重写父类 a = new 重写子类();
2929
a.b();
3030
}
3131

0 commit comments

Comments
 (0)