With this post I just want to show how to convert a Java collection into an array and how to convert a wrapper class array into an array of the corresponding primitive data type. As a bonus I will show how to iterate over an ArrayList.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | public static void main(String[] args) { // Java collection (ArrayList) with Floats ArrayList<Float> someFloats = new ArrayList<Float>(); someFloats.add(3.72f); someFloats.add(28.07f); someFloats.add(2011f); // Convert ArrayList into an array Float[] floatWrapperArray = someFloats.toArray(new Float[someFloats.size()]); float[] floatArray = new float[floatWrapperArray.length]; // Transfer array of Wrapper type (Float) into array of primitive data type (float) for (int i = 0; i < floatArray.length; i++) { floatArray[i] = floatWrapperArray[i].floatValue(); } // 1. Float ArrayList System.out.println("1. Float ArrayList"); for (Iterator iterator = someFloats.iterator(); iterator.hasNext();) { Float currentFloat = (Float) iterator.next(); System.out.println(currentFloat); } // 2. Float array System.out.println("2. Float array"); for (int i = 0; i < floatWrapperArray.length; i++) { System.out.println(floatWrapperArray[i]); } // 3. float array System.out.println("3. float array"); for (int i = 0; i < floatArray.length; i++) { System.out.println(floatArray[i]); } } |
Output
1 2 3 4 5 6 7 8 9 10 11 12 | 1. Float ArrayList 3.72 28.07 2011.0 2. Float array 3.72 28.07 2011.0 3. float array 3.72 28.07 2011.0 |
Bei der Suche nach geeigneten Tutorials zu regulären Ausdrücken bin ich auf dieses fantastische Video gestoßen:
Wer lieber lesen möchte, dem empfehle ich das Java Regex Tutorial von Lars Vogel. Zum Testen von regulären Ausdrücken eignet sich regexpal.
Zwischen 0-6 Uhr kann man beim Mindfactory Midnight-Shopping versandkostenfrei bestellen.
This code shows how to draw a simple triangle with OpenGL ES (OpenGL 1.0) on the screen of an Android mobile device. It is based on the tutorial OpenGL ES Tutorial for Android – Part I – Setting up the view from the Jaway Team Blog. To keep things simple I decided to implement only the necessary parts and to comment things that are not obvious. Please note that the class …weiterlesenGL10 stands for OpenGL 1.0.
Der Mozilla Firefox beherrscht die wahnsinnig praktische Funktion, bei Eingabe eines Suchwortes in der Adresszeile, direkt auf Google danach zu suchen. Man muss es ihm/ihr nur beibringen. Das geht wie folgt:
about:configin die Adresszeile eingebenkeyword.URLim “Filter” der Konfiguration eingebenhttp://www.google.de/search?ie=UTF-8&q=als String für diekeyword.URLeingeben
Vielen Dank an den Beitrag “Google-Suche in Adresszeile” aus dem Männerblog.
In Linux können Prozesse mit dem Tool screen im Hintergrund ausgeführt werden. Dazu sind nur folgende Befehle aus der Konsole nötig:
1 2 3 | screen -S mein_prozess Strg+A+D screen -rx mein_prozess |
Erklärung:
- Legt einen neuen Hintergrundprozess an, der Name für
mein_prozessist frei wählbar - Mit der Tastenkombination
Strg+A+D(Tasten zügig nacheinander drücken), kann man aussceenwieder ins Terminal wechseln - Mit dem Aufruf von
screen -rxkann wieder zum Hintergrundprozess zurückgekehrt werden

0