Skip to content

Commit e631ca8

Browse files
committed
新增:对象含有String作为方法参数传递
1 parent 86073e7 commit e631ca8

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.javacore.base.String; /*
2+
* Copyright [2015] [Jeff Lee]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* @author BYSocket
19+
* @since 2016-01-06 20:07:00
20+
* 对象含有String作为方法参数传递
21+
*/
22+
public class StringT2 {
23+
24+
public static void main(String[] args) {
25+
StringObject sb = new StringObject();
26+
sb.setName("123");
27+
change(sb);
28+
System.out.println(sb.getName());
29+
}
30+
31+
public static void change(StringObject sb) {
32+
sb = new StringObject();
33+
sb.setName("456");
34+
}
35+
36+
}
37+
class StringObject {
38+
String name;
39+
40+
public String getName() {
41+
return name;
42+
}
43+
44+
public void setName(String name) {
45+
this.name = name;
46+
}
47+
}

0 commit comments

Comments
 (0)