> Then, i've a method:
>
[quoted text clipped - 26 lines]
>
> Who can help me???
Hello Marino,
in order to create a clone of any kind of (Object)-array I would use the
static method arraycopy from java.lang.System:
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
Copies an array from the specified source array, beginning at
the specified position, to the specified position of the destination
array.
Mariano - 01 Apr 2007 18:48 GMT
> In article <1175447288.612216.287...@n59g2000hsh.googlegroups.com>,
>
[quoted text clipped - 37 lines]
> the specified position, to the specified position of the destination
> array.
import java.lang.System
//...
arraycopy(creaLista(rs, "SINTOMO"), 0, SINTOMO, 2);
but arraycopy() is not found by my class
Lew - 01 Apr 2007 18:51 GMT
> import java.lang.System
> //...
> arraycopy(creaLista(rs, "SINTOMO"), 0, SINTOMO, 2);
>
> but arraycopy() is not found by my class
That's because you didn't give the class name, as is always required to invoke
static methods.
System.arraycopy( ...
-- Lew
Arne Vajhøj - 01 Apr 2007 19:45 GMT
>> import java.lang.System
>> //...
[quoted text clipped - 6 lines]
>
> System.arraycopy( ...
Since 1.5 you can actually do:
import static java.lang.System.*;
(not that I would recommend it)
Arne
Mariano - 01 Apr 2007 21:38 GMT
> >> import java.lang.System
> >> //...
[quoted text clipped - 14 lines]
>
> Arne
I've resolve the problem thank you all :)
Lew - 02 Apr 2007 02:33 GMT
Lew wrote:
>>> That's because you didn't give the class name, as is always required to
>>> invoke static methods.
>>> System.arraycopy( ...
Arne Vajhøj <a...@vajhoej.dk> wrote:
>> Since 1.5 you can actually do:
>>
>> import static java.lang.System.*;
>>
>> (not that I would recommend it)
Which is another way to give the class name, as is always required to invoke
static methods.
(not that I would recommend it - except that others have pointed out certain
situations where it could benefit, maybe)
-- Lew
Lew - 01 Apr 2007 18:50 GMT
> in order to create a clone of any kind of (Object)-array I would use the
> static method arraycopy from java.lang.System:
[quoted text clipped - 3 lines]
> the specified position, to the specified position of the destination
> array.
Or java.util.Arrays.copyOf(T[], int) and its cousins.
<http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(T[],%20int)>
-- Lew
Piotr Kobzda - 01 Apr 2007 19:02 GMT
>> in order to create a clone of any kind of (Object)-array I would use
>> the static method arraycopy from java.lang.System:
[quoted text clipped - 6 lines]
> Or java.util.Arrays.copyOf(T[], int) and its cousins.
> <http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(T[],%20int)>
Or simply .clone() an array.
piotr
> public class Paziente extends javax.swing.JFrame {
> private String[] sin;
[quoted text clipped - 10 lines]
> sin[i] I obtain an out of bound exception, also if creaLista() have an
> array grater than 1 element.
I'm a bit confused as to what your code is attempting. The code above
wont OOBE. Is creaLista actually returning a reference to the array that
is already assigned to sin? If so, that is very confusing. Either don't
return it, or don't update the instance variable.
Other replies point to the mechanics of copying into an array of an
appropriate size. However rather than doing that, I suggest declaring
and initialising sin as:
private final List<String> sin = new java.util.ArrayList<String>();
There is no need to complicate your code with low level details which
have already be solved elsewhere.
Tom hawtin