🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #154228

Re: Zwracanie dwóch (kilku) rzeczy przez metodę

#154228
From: Piotr Rezmer
Date: Fri, 17 Jul 2015 20:06
40 lines
1883 bytes
W dniu 2015-07-17 o 18:11, Borneq pisze:

> Jakie są inne możliwości? Ustawianie pola w obiekcie?

Tak, np. jak używasz Axis do generacji kodu klienta Web Services, jeśli 
masz argument w stylu out to używana jest klasa pomocnicza. Np. jeśli 
masz metodę z sygnaturką

Foo( out int arg1, out int arg2 )

To używane są klasy IntHolder które mają pole intValue. I oczywiście są 
podobne klasy dla innych typów podstawowych.

Ogólne lepiej jest jeśli metoda zwraca jedną zmienną wynikową. Jeśli 
wydaje się to nielogiczne, a zwracane wyniki tworzą jakąś logiczną 
całość to warto użyć obiektu-kontenera, np. coś w rodzaju

public GpsCoordinates getCurrentLocation() {
}

public class GpsCoordinates {

private xPos float;
private yPos float;

public float getLongtitude() {
return xPos;
}

public float getLattitude() {
return yPos;
}

}


-- 
pozdrawiam
Piotr
XLR250&bmw_f650_dakar
Technical Details
Message-ID: <mobn8j$5bu$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <mob9g4$mn4$1@node1.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Piotr Rezmer <konta@doman.pl>
Newsgroups: pl.comp.lang.java
Subject: Re: Zwracanie dwóch (kilku) rzeczy przez
 metodę
Date: Fri, 17 Jul 2015 22:06:50 +0200
Organization: ATMAN - ATM S.A.
Lines: 40
Message-ID: <mobn8j$5bu$1@node1.news.atman.pl>
References: <mob9g4$mn4$1@node1.news.atman.pl>
NNTP-Posting-Host: apn-77-115-39-253.dynamic.gprs.plus.pl
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1437163603 5502 77.115.39.253 (17 Jul 2015 20:06:43 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Fri, 17 Jul 2015 20:06:43 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <mob9g4$mn4$1@node1.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit