Array in ein anderes Array kopieren

Status
Nicht offen für weitere Antworten.

MQue

Top Contributor
Hallo nochmal,

ich steh ein bisschen auf der Leitung und zwar möchte ich ein Array in ein anderes kopieren aber es klappt nicht ganz.
Vielen dank!!!

lg Michl

Code:
int numBytes = ins.read(readBuf);

private byte[] readBuf = new byte[100];
public static int[] Arr = new int[100]; 

System.arraycopy(readBuf,0,Arr,0,numBytes);
 
nein das kanns nicht sein, ich glaub der fehler liegt eher an dem, dass ich ein byte- Array in ein int- Array kopieren will.
Das Programm hängt jedenfalls an dieser Stelle.

lg und Danke
 
for-Schleife benutzen?
Code:
private byte buf[] = //Hier das byte-Array initialisieren
public int Arr[] = new int[buf.length];

for (int i = 0; i < buf.length; i++)
 Arr[i] = (int) buf[i];
 
jop ..verschiedene typen schluckt er nicht....voll übersehen

dazu API
* The src argument refers to an object that is not an array.
* The dest argument refers to an object that is not an array.
* The src argument and dest argument refer to arrays whose component types are different primitive types.
* The src argument refers to an array with a primitive component type and the dest argument refers to an array with a reference component type.
* The src argument refers to an array with a reference component type and the dest argument refers to an array with a primitive component type.
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben