Redian新闻
>
能否让函数返回一个用于赋值的引用
avatar
能否让函数返回一个用于赋值的引用# Java - 爪哇娇娃
m*9
1
就在
Gym!
avatar
B*0
2
我们这儿松鼠多, 我种的大蒜都被它们抛出来了. 请问有什么方法可以让它们不来骚
扰吗?
avatar
x*n
3
Dan Fogelberg-Sutter‘s mill
In the Spring of Forty-seven,
So the story, it is told,
Old John Sutter went to the mill site
Found a piece of shining gold.
Well, he took it to the city
Where the word, like wildfire, spread.
And old John Sutter soon came to wish he'd
Left that stone in the river bed.
For they came like herds of locusts
Every woman, child and man
In their lumbering Conestogas
They left their tracks upon the land.
(Chorus)
Some would fail and some would prosper
Some would die and some
avatar
b*i
4
我有一个类叫storage,其中有个数组string ok[100];
还有个acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
storage m;
string& mystring=m.acquirereference(10);
mystring="ok";
可以让ok[10]获得"ok"。 应该怎样写呢?
avatar
c*e
5
锻炼看球两不误
avatar
F*k
6
养猫/狗
avatar
wh
7
噢噢噢我对不起你的小斜杠……这个是啥意思?
还有采访一下:你对slumdog millionaire得那么多奥斯卡有啥感想?你是这里第一个
说起这个电影的。

【在 x**n 的大作中提到】
: Dan Fogelberg-Sutter‘s mill
: In the Spring of Forty-seven,
: So the story, it is told,
: Old John Sutter went to the mill site
: Found a piece of shining gold.
: Well, he took it to the city
: Where the word, like wildfire, spread.
: And old John Sutter soon came to wish he'd
: Left that stone in the river bed.
: For they came like herds of locusts

avatar
c*t
8
1. 你写的不清楚
2. 你该到 programming 版问。。。你的代码又不是 java

【在 b***i 的大作中提到】
: 我有一个类叫storage,其中有个数组string ok[100];
: 还有个acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
: storage m;
: string& mystring=m.acquirereference(10);
: mystring="ok";
: 可以让ok[10]获得"ok"。 应该怎样写呢?

avatar
t*o
9
才发现?
avatar
S*p
10
啊?松鼠连大蒜都吃啊,我还以为所有鼠辈根本不会碰大蒜呢
根据前辈的经验,唯一能防住松鼠的方法是弄个网把整个菜地罩起来
avatar
wh
11
《三步杀人曲》是once upon a time in mexico吗?这个视频应该是,我记得藏在吉他
里面的枪。你最近老做淘金梦?上次是个diamond.

【在 x**n 的大作中提到】
: Dan Fogelberg-Sutter‘s mill
: In the Spring of Forty-seven,
: So the story, it is told,
: Old John Sutter went to the mill site
: Found a piece of shining gold.
: Well, he took it to the city
: Where the word, like wildfire, spread.
: And old John Sutter soon came to wish he'd
: Left that stone in the river bed.
: For they came like herds of locusts

avatar
b*i
12
是java,如果原来的代码是c++, 就是我写的那样,可以用引用或者指针获得地址,从而
给变量赋值。现在要转换成java,如何写呢?
C++程序如下
我有一个类叫storage,其中有个数组double ok[100];
还有个方法acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
storage m;
double& storage::acquirereference(int a)
{
return ok[a];
}
double& myvalue=m.acquirereference(10);// here to get &ok[10] as in c++
myvalue=5;可以让ok[10]获得5。
应该怎样写java的方法acquirereference的返回值类型和return 的参数呢?

【在 c*****t 的大作中提到】
: 1. 你写的不清楚
: 2. 你该到 programming 版问。。。你的代码又不是 java

avatar
B*0
13
它们不吃 但是会捣乱
avatar
x*n
14
呵呵,没感想呀。我星期天就看了一顶点,就忙其他事去了。

【在 wh 的大作中提到】
: 噢噢噢我对不起你的小斜杠……这个是啥意思?
: 还有采访一下:你对slumdog millionaire得那么多奥斯卡有啥感想?你是这里第一个
: 说起这个电影的。

avatar
g*g
15
You can't do that, but you can return the array and the index
and use ok[i] to assign the value.

【在 b***i 的大作中提到】
: 是java,如果原来的代码是c++, 就是我写的那样,可以用引用或者指针获得地址,从而
: 给变量赋值。现在要转换成java,如何写呢?
: C++程序如下
: 我有一个类叫storage,其中有个数组double ok[100];
: 还有个方法acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
: storage m;
: double& storage::acquirereference(int a)
: {
: return ok[a];
: }

avatar
x*n
16
俗话说得好呀:人为财活,鸟为食飞。

【在 wh 的大作中提到】
: 《三步杀人曲》是once upon a time in mexico吗?这个视频应该是,我记得藏在吉他
: 里面的枪。你最近老做淘金梦?上次是个diamond.

avatar
a*i
17
try
public class Storage {
String[] ok;
public set(int index, String value) {
ok[index] = value;
}
}
class Main {
public static void main (String[] args) {
Storeage m = new Storeage();
String mystring = "ok";
m.set(10, mystring);
}
}
there is no way to get the reference and assign it.
String objects are immutable.

【在 b***i 的大作中提到】
: 我有一个类叫storage,其中有个数组string ok[100];
: 还有个acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
: storage m;
: string& mystring=m.acquirereference(10);
: mystring="ok";
: 可以让ok[10]获得"ok"。 应该怎样写呢?

avatar
wh
18
不是问颁奖仪式的观后感呀,是问它得了那么多奥斯卡,你觉得值不值啊?因为听人说
它没那么好。我是记得你看完挺推荐的。话说昨晚我看了一半的orz boyz.
你这个签名档,就是自己敲着玩?呵呵。

【在 x**n 的大作中提到】
: 呵呵,没感想呀。我星期天就看了一顶点,就忙其他事去了。
avatar
h*0
19
在C里,你返回ok[10]或者ok[20]都是一样的吧?反正也不做下标越界检查的。

【在 b***i 的大作中提到】
: 是java,如果原来的代码是c++, 就是我写的那样,可以用引用或者指针获得地址,从而
: 给变量赋值。现在要转换成java,如何写呢?
: C++程序如下
: 我有一个类叫storage,其中有个数组double ok[100];
: 还有个方法acquirereference(int a)想返回ok[a]的引用,比如我在主程序中
: storage m;
: double& storage::acquirereference(int a)
: {
: return ok[a];
: }

avatar
x*n
20
我觉得很好, 其他的都没看过。
那个签名就是敲着完。 呵呵。

【在 wh 的大作中提到】
: 不是问颁奖仪式的观后感呀,是问它得了那么多奥斯卡,你觉得值不值啊?因为听人说
: 它没那么好。我是记得你看完挺推荐的。话说昨晚我看了一半的orz boyz.
: 你这个签名档,就是自己敲着玩?呵呵。

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