Redian新闻
>
java 的函数 xxx(a, b,c)能够向a 写入数据吗?
avatar
java 的函数 xxx(a, b,c)能够向a 写入数据吗?# Java - 爪哇娇娃
O*o
1
I had a friend whoese major was Industrial design. She is doing some work
like this which might be interesting to Goldy.
avatar
A*o
2
我其实没有多大,95年,但是老是喜欢追着别人给我讲鬼故事。我先来说一个自己身边
的。
这个事情是发生在我上五年级的时候隔壁村的事情,不知道你们农村有没有庙我们这里
每个农村都有庙,不管是大的还是小的都有庙,发生事情的是比我高一年级的女孩子,
她是在温堂村,在这个简称a吧,她们村子有个大庙,每年几月几号都会找戏班子去她
们村子唱戏具体时间不知道,a呢是自己在家,爸妈都没有在家,那年她们村里唱戏,a
和她的同学去庙里,烧了一炷香,香插上不到10秒就烧完了,庙里会有一些懂这个的,
就告诉a,说姑娘你家今天有急事,多注意一下,a笑笑什么都没有说就走了,a和她的
同学去了我们镇上买东西,回来的时候走到隔壁村的时候,被后面来的拖拉机和挂倒了
,当时说是被头挂倒,当时a没有什么大事,还没有起来又被拖拉机的后轱辘从脑袋上
压了过去。和她一起的同学,吓晕了过去,等a的同学醒过来的时候,a的同学一直和她
家里人说a想让她陪a一起去,a还说好冷
avatar
b*i
3
看起来,如果a是数组,则数组里面的值可以修改,
如果是int, 则不能改。这里面的规则是什么?
avatar
O*o
4


【在 O*******o 的大作中提到】
: I had a friend whoese major was Industrial design. She is doing some work
: like this which might be interesting to Goldy.

avatar
r*s
5
pass by reference and pass by value

【在 b***i 的大作中提到】
: 看起来,如果a是数组,则数组里面的值可以修改,
: 如果是int, 则不能改。这里面的规则是什么?

avatar
g*y
6
这是什么,创意设计?
让我也去跟着做这个?

【在 O*******o 的大作中提到】

avatar
b*i
7
我 的 理解是,java把参数放进堆栈,然后呼叫函数,
如果堆栈中是int,显然不能改变。
如果堆栈中是一个数组的地址,则数组内容可变。

【在 r*****s 的大作中提到】
: pass by reference and pass by value
avatar
a*d
8
其实这个一般的视觉传达设计就可以做了。industrial design去做这个,可惜了啊

【在 O*******o 的大作中提到】
: I had a friend whoese major was Industrial design. She is doing some work
: like this which might be interesting to Goldy.

avatar
g*g
9
It's always pass by reference for object and pass by value
for primitive. Array is an object and values in object can
be changed.

【在 b***i 的大作中提到】
: 看起来,如果a是数组,则数组里面的值可以修改,
: 如果是int, 则不能改。这里面的规则是什么?

avatar
O*o
10
hehhehehehheeheheheheheheheheheh, calm down, calm down. those stuff are for
sales

【在 g***y 的大作中提到】
: 这是什么,创意设计?
: 让我也去跟着做这个?

avatar
e*3
11
Java一直都是pass by value的,只不过object的value是reference罢了。

【在 g*****g 的大作中提到】
: It's always pass by reference for object and pass by value
: for primitive. Array is an object and values in object can
: be changed.

avatar
wh
12
继续读学位吧?有个志同道合的圈子,继续深造,做自己喜欢做的事。

【在 g***y 的大作中提到】
: 这是什么,创意设计?
: 让我也去跟着做这个?

avatar
x*p
13
Java is always pass by references. For primitive types, in Java 5, it is
considered as a object by autoboxing. Thus it is still pass by references.
The reason why the value of a primitive can not be changed outside the
function is because that the corresponding object of the primitive is
immutable.
Look at the following two examples.
1. void foo(String str) { str = "inFoo"; }
String s = "abc";
foo(s);
System.out.println(s);
The output is abc, not inFoo. String is an object, but it is immutable. so
its value can not be changed and thus looks like pass by value.
2. class A { int x = 10; }
void foo(A a) { a.x = 20; }
A a = new A();
foo(a);
System.out.println(a.x);
The output is 20, not 10. It is pass by references and the value is changed
after the function call.
avatar
g*y
14
我随口问的,没激动。。。。不好意思,就是开头不理解你什么意思。。。呵呵

for

【在 O*******o 的大作中提到】
: hehhehehehheeheheheheheheheheheh, calm down, calm down. those stuff are for
: sales

avatar
b*i
15
我的理解
java是pass by value。所以,传入一个整数作为参数到函数里面是不能改变函数外面
那个 变量的值 的。
而那些复杂的类,传入的是类的地址的值。在这里,类的值就是变量地址的值。因为
java里面不讲地址,但本质上就是堆栈里面的地址。当你传入类变量的地址,当然可以
根据地址改变地址指向的那个数据,但是不能改变该变量本身的地址。这和C语言里面
传入一个指针,可以改变指针指向的数据,但是不能改变指针本身是一样的。

【在 x*****p 的大作中提到】
: Java is always pass by references. For primitive types, in Java 5, it is
: considered as a object by autoboxing. Thus it is still pass by references.
: The reason why the value of a primitive can not be changed outside the
: function is because that the corresponding object of the primitive is
: immutable.
: Look at the following two examples.
: 1. void foo(String str) { str = "inFoo"; }
: String s = "abc";
: foo(s);
: System.out.println(s);

avatar
g*y
16
恩,是啊,还是读书好一些也简单一点。。。

【在 wh 的大作中提到】
: 继续读学位吧?有个志同道合的圈子,继续深造,做自己喜欢做的事。
avatar
g*e
17
java is pass by value

【在 x*****p 的大作中提到】
: Java is always pass by references. For primitive types, in Java 5, it is
: considered as a object by autoboxing. Thus it is still pass by references.
: The reason why the value of a primitive can not be changed outside the
: function is because that the corresponding object of the primitive is
: immutable.
: Look at the following two examples.
: 1. void foo(String str) { str = "inFoo"; }
: String s = "abc";
: foo(s);
: System.out.println(s);

avatar
wh
18
嗯,而且是你喜欢做的事。可以着手准备申请,很花时间的。业余时间写游记……我跟
你比看谁写得快吧,我大概写九篇十篇左右,一个城市一篇。但还想写其他。预计夏天
之前可以写完……

【在 g***y 的大作中提到】
: 恩,是啊,还是读书好一些也简单一点。。。
avatar
m*r
19
我觉得, 其实大家都知道怎么回事。 混乱在于, 对pass by reference/pass by
value的理解错误。
java is pass by value.
pass by reference has a simple test:
swap(YourType a, YourType b) {
YourType temp;
temp = a;
a = b;
b = temp;
}
如果这个过了, 就是pass by reference。

【在 g**e 的大作中提到】
: java is pass by value
avatar
x*p
20
In C/C++, value and reference has strict definition. Reference only means
the address of an object and the value means the content of the object.
However, Java messed up the two concepts. Lots of books say that Java is
pass by value, and actually mean "pass by the value of the reference". So in
Java, value and reference are the same thing. That is why it confused so
many people and create a big fight among even top Java players in the world.
In US industry, the answer is unique: Java is pass by reference.
avatar
g*e
21
pass by the value of the reference
这句话靠谱
US哪个industry说java pass by reference的?

in
world.

【在 x*****p 的大作中提到】
: In C/C++, value and reference has strict definition. Reference only means
: the address of an object and the value means the content of the object.
: However, Java messed up the two concepts. Lots of books say that Java is
: pass by value, and actually mean "pass by the value of the reference". So in
: Java, value and reference are the same thing. That is why it confused so
: many people and create a big fight among even top Java players in the world.
: In US industry, the answer is unique: Java is pass by reference.

avatar
e*g
22
exactly, for primitive types(8 types, boolean, char, short, int, long, float
, double) types pass by value
for objects pass the reference of objects

【在 e********3 的大作中提到】
: Java一直都是pass by value的,只不过object的value是reference罢了。
avatar
a*e
23
C语言你传一个结构的变量给函数,变量的值是不变的;
Java你传一个类的对象给方法,那对象的值是可变的。
所以C的传值更严格。Sun自己的Java Tutorial在1.4和以前都说是传
参,到1.5时才改为传值。

【在 b***i 的大作中提到】
: 我的理解
: java是pass by value。所以,传入一个整数作为参数到函数里面是不能改变函数外面
: 那个 变量的值 的。
: 而那些复杂的类,传入的是类的地址的值。在这里,类的值就是变量地址的值。因为
: java里面不讲地址,但本质上就是堆栈里面的地址。当你传入类变量的地址,当然可以
: 根据地址改变地址指向的那个数据,但是不能改变该变量本身的地址。这和C语言里面
: 传入一个指针,可以改变指针指向的数据,但是不能改变指针本身是一样的。

avatar
x*p
24
美国工业界,都是回答Java is pass by reference,or the value of the reference
avatar
G*o
25
support... pass by reference...
avatar
h*0
26
这理解得完全莫名其妙……

【在 x*****p 的大作中提到】
: Java is always pass by references. For primitive types, in Java 5, it is
: considered as a object by autoboxing. Thus it is still pass by references.
: The reason why the value of a primitive can not be changed outside the
: function is because that the corresponding object of the primitive is
: immutable.
: Look at the following two examples.
: 1. void foo(String str) { str = "inFoo"; }
: String s = "abc";
: foo(s);
: System.out.println(s);

avatar
h*0
27
对于对象,是这样的。对于int这种,你居然还敢说passed by reference,还找出一个
不靠谱的例子,说出"auto-boxing"这种跟本话题完全不相关的内容。

in
world.

【在 x*****p 的大作中提到】
: In C/C++, value and reference has strict definition. Reference only means
: the address of an object and the value means the content of the object.
: However, Java messed up the two concepts. Lots of books say that Java is
: pass by value, and actually mean "pass by the value of the reference". So in
: Java, value and reference are the same thing. That is why it confused so
: many people and create a big fight among even top Java players in the world.
: In US industry, the answer is unique: Java is pass by reference.

avatar
h*0
28
因为Java里其实没有对象变量。你看起来是传一个类的对象给方法,但其实传的是那个
对象的指针。Java里是不能用对象给对象赋值的。只能指针间赋值。

【在 a**e 的大作中提到】
: C语言你传一个结构的变量给函数,变量的值是不变的;
: Java你传一个类的对象给方法,那对象的值是可变的。
: 所以C的传值更严格。Sun自己的Java Tutorial在1.4和以前都说是传
: 参,到1.5时才改为传值。

avatar
h*0
29
这个绝对是指非基本类型。

reference

【在 x*****p 的大作中提到】
: 美国工业界,都是回答Java is pass by reference,or the value of the reference
: 。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。