Article View: borland.public.jbuilder.java.language
Article #8532Re: Simple question for gurus ;)
From: Stefan Adolfsson
Date: Tue, 20 Mar 2001 16:03
Date: Tue, 20 Mar 2001 16:03
103 lines
3633 bytes
3633 bytes
One solution is to use an array of size 1, arrays are are changed and
not copied.. working program this time ..
Ill try to get a better solution and get back to u...
class Hej {
Hej() {
int[] a = new int[1];
a[0]=0;
System.out.println(a[0]);
change(a);
System.out.println(a[0]);
}
public void change(int b[]) {
b[0]=7;
}
public static void main(String args[]) {
Hej newProg = new Hej();
}
}
On Tue, 20 Mar 2001 11:05:29 +0100, "Nikola Mitrovic"
<nikola@mail.com> wrote:
>Nope, won't work;
>
>First, there is no method set, and there is no method .valueOf(int), so I
>guess you must use .decode(String), or .parseInt(String). But guess, it
>wont'k work then either!
>
>Also, the same thing with String class doesn't work, and String is an
>object, and can be easiliy assigned, concatenated, etc...
>
>what I did more is to say
>
> test (Integer param) {
> Integer param2 = new Integer(5);
> param = param2;
> }
>
>but it didn't work either, and it should since, it should be pointer
>assignment...
>
>plz, any working example?
>
>"Stefan Adolfsson" <stefan.adolfsson@usa.net> wrote in message
>news:3ab688c8.43123726@news.cs.umu.se...
>> Use the integer as an object,,,
>> instead of:
>> int param ;
>> do:
>> Integer param;
>> then the integer will work as an object which is changed directly in
>> java and not copied.
>> example:
>>
>> public void test(Integer param) { param.set(5);
>> }
>>
>> public void example(){
>> Integer example_parameter = new Integer(0);
>> test( example_parameter );
>> System.out.println("parameter: " + example_parameter);
>> }
>>
>>
>>
>>
>>
>> On Mon, 19 Mar 2001 21:29:30 +0100, "John Good"
>> <dumster@collector.org> wrote:
>>
>> >
>> >I've got a strange problem with Java, it's probably a feature, but please
>> >point me to solving this.
>> >
>> >If I have something like:
>> >
>> >public void test(int param) { param = 5;
>> >}
>> >
>> >and practically want to set the param to 5 (I do not want to use return,
>> >please!), and when I call it from another method, like:
>> >
>> >public void example(){
>> > int example_parameter = 0;
>> > test( example_parameter );
>> > System.out.println("parameter: " + example_parameter);
>> >}
>> >
>> >I'll get the 0 as the output, and I want 5; how to assign a value a
>> >parameter? (pointers I miss you ;)
>> >I've checked some books on that, but as allways its not in it, because
>it's
>> >"too obvious"...
>> >
>> >plz help :)
>> >
>> >
>>
>
>
Technical Details
Message-ID:
<3ab77ebc.28129735@news.cs.umu.se>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed2.news.nl.uu.net!sun4nl!surfnet.nl!newsfeed.sunet.se!news01.sunet.se!news.umu.se!not-for-mailReferences:
<Z_tt6.19$xH3.1481@psinet-eu-nl> <3ab688c8.43123726@news.cs.umu.se> <2YFt6.4$mR5.423@psinet-eu-nl>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,a90669a07786d662 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-20 08:52:14 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed2.news.nl.uu.net!sun4nl!surfnet.nl!newsfeed.sunet.se!news01.sunet.se!news.umu.se!not-for-mail From: stefan.adolfsson@usa.net (Stefan Adolfsson) Newsgroups: borland.public.jbuilder.java.language Subject: Re: Simple question for gurus ;) Date: Tue, 20 Mar 2001 16:03:34 GMT Organization: News UmU SE Lines: 104 Message-ID: <3ab77ebc.28129735@news.cs.umu.se> References: <Z_tt6.19$xH3.1481@psinet-eu-nl> <3ab688c8.43123726@news.cs.umu.se> <2YFt6.4$mR5.423@psinet-eu-nl> NNTP-Posting-Host: flintv158.sn.umu.se X-Trace: hudsucker.umdac.umu.se 985104521 7743 130.239.145.212 (20 Mar 2001 16:08:41 GMT) X-Complaints-To: newsmaster@umu.se NNTP-Posting-Date: Tue, 20 Mar 2001 16:08:41 +0000 (UTC) X-Newsreader: Forte Free Agent 1.21/32.243