Unterschiede

Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.

java:arraylist_to_array 2008/04/07 14:04 java:arraylist_to_array 2020/01/22 20:59 aktuell
Zeile 1: Zeile 1:
-====== ArrayList, umwandeln in ein Array ======+[[java|Java - Allgemein]]\\ 
 +====== ArrayList, umwandeln in ein Array (ArrayList to array) ====== 
 +//java.util.ArrayList//\\ 
 +<html> 
 +  <script type="text/javascript"><!-- 
 +      google_ad_client="pub-9681858985507948"; 
 +      google_ad_width = 468; 
 +      google_ad_height = 60; 
 +      google_ad_format = "468x60_as"; 
 +      google_ad_type = "text"; 
 +      google_ad_channel = ""; 
 +      google_color_border = "cccccc"; 
 +      google_color_bg = "FFFFFF"; 
 +      google_color_link = "1d2d8c"; 
 +      google_color_text = "000000"; 
 +      google_color_url = "1d2d8c"; 
 +      //--> 
 +  </script> 
 +  <script type="text/javascript" 
 +      src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
 +  </script> 
 +</html> 
 +\\
<code java> <code java>
// Das Ausgangs-Array: // Das Ausgangs-Array:
-String[] strs = {"Apfel", "Birne", "Banane"};+String[] strs = {"Apfel", "Birne", "Banane", "Pflaume"}; 
// Alle Elemente in eine ArrayList packen: // Alle Elemente in eine ArrayList packen:
-ArrayList<String> al = new ArrayList<String>(); +ArrayList<String> al = new ArrayList<String>(Arrays.asList(strs)); 
-for (int i=0; i < strs.length; i++) +
-  al.add(strs[i]);+
// Nun die ArrayList wieder in ein Array konvertiert: // Nun die ArrayList wieder in ein Array konvertiert:
String[] strs2 = al.toArray(new String[0]);  String[] strs2 = al.toArray(new String[0]); 
 +</code>
 +\\
 +\\
 +\\
 +Stichworte:
 +<code>
 +ArrayList List to Array konvertieren
</code> </code>

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007