🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #26543

Re: ¿como puedo modificar una variable en funcion run( ) desde otra funcion?

#26543
From: Jonathan Revusky
Date: Sat, 12 Dec 1998 00:00
56 lines
1671 bytes

Juan Gonzalo de Silva Medina wrote:
> 

> Creo que lo puedes hacer utilizando objetos:
> 
> public void run()
> {
>         Integer d = new Integer(4);
>         Integer e = new Integer(5);
>         CabiaValores(d,e);
> }
> 
> CambiaValores( Integer d, Integer e)
> {
>         d = new Integer(7);
>         e = new Integer(8);
> }

No, tampoco funciona. :-)

> Otra forma es ponerlos como atributos del objeto, con lo que no tendrias
> ning�n problema.

S�, o quiz� utilizar un array.

�Por qu� esa persona necesita que sean variables locales?
(Con variables locales as�, en efecto, no se puede hacer lo que quiere.)

As� que:

int d, e;

public void run()
{
     d = 4;
     e = 5;
     CambiaValores();
}

void CambiaValores()
{
      d = 7;
      e = 8;
}

�Eso s� que funciona!


Jonathan Revusky
-- 
Java and Delphi Consulting
Make your .class files double-clickable
with SmartJ
http://www.bigfoot.com/~crystalline.solutions
Technical Details
Message-ID: <3671EC92.B814FC2C@jet.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36692096.248109@noticias.ibernet.es> <3671BFED.3779F854@caymasa.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: 1116f3,f552d29059f4c68d
X-Google-Attributes: gid1116f3,public
From: Jonathan Revusky <jrevusky@jet.es>
Subject: Re: ¿como puedo modificar una variable en funcion run( ) desde otra funcion?
Date: 1998/12/12
Message-ID: <3671EC92.B814FC2C@jet.es>
X-Deja-AN: 421548433
Content-Transfer-Encoding: 8bit
References: <36692096.248109@noticias.ibernet.es> <3671BFED.3779F854@caymasa.es>
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
Organization: Telefonica Transmision de Datos
Mime-Version: 1.0
Reply-To: jrevusky@bigfoot.com
Newsgroups: es.comp.lenguajes.java