Tag Archives: java

10,274 views

Round number float – double to int – long Java example

int nf = Math.round(5.789f); System.out.print(nf); // 6   float f = 28.611f; int n3 = Math.round(f); System.out.println(n3); // 29   double d = 1234.56; long lon = Math.round(d); System.out.println(lon); // 1235   int diff = 90 – 40; // float … Continue reading

Posted in Android Examples Code | Tagged , | Comments Off on Round number float – double to int – long Java example
4,018 views

Iterate HashMap getKey getValue Java Example

HashMap<String,Locale> _mapOfLocale = new HashMap<String,Locale>(); _mapOfLocale.put("French",Locale. FRENCH ); _mapOfLocale.put("German",Locale. GERMAN ); _mapOfLocale.put("Italian",Locale. ITALIAN );   for (Entry<String, Locale> entry : _mapOfLocale.entrySet()) {   System.out.println(entry.getKey()); System.out.println(entry.getValue());   }

Posted in Android Examples Code, Array,List,Collections | Tagged , , | Comments Off on Iterate HashMap getKey getValue Java Example
6,614 views

Array copy to Array Java Android example

String[] source = {"Hello","world","by","Android"};   String[] destination = new String[source.length];   System.arraycopy(source, 0, destination, 0, source.length);

Posted in Android Examples Code | Tagged , , , | Comments Off on Array copy to Array Java Android example
5,082 views

Map TreeMap get values to array Java Android example

import java.util.Map; import java.util.TreeMap;   public class MainClass { public static void main(String[] arg) {   // english;germany dictionary String[] arrayOfString = { "one;eine", "two;zwei", "two sets of;zwei" , "three;drei", "four;vier" };   Map<String, String> map = new TreeMap<String, String>(); … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , | Comments Off on Map TreeMap get values to array Java Android example
5,950 views

Map TreeMap get key by value Java Android example

Get key by value from Map Java Android example MainClass.java import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap;   public class MainClass { public static void main(String[] arg) {   // english;germany dictionary String[] arrayOfString = … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , | Comments Off on Map TreeMap get key by value Java Android example
13,622 views

Hashtable key value pair add put get pair Java Android example

How add pair of strings to Hashtable, how get pair key value from Hashtable, how split string, basic Java Android example. MainClass.java import java.util.Enumeration; import java.util.Hashtable; public class MainClass { public static void main(String[] arg) {   // english;germany dictionary … Continue reading

Posted in Android Examples Code, Array,List,Collections | Tagged , , , , , | Comments Off on Hashtable key value pair add put get pair Java Android example
6,634 views

Switch Statement Java basic example

Switch statement with numbers and array of strings Java example. public class MainClass { public static void main(String[] arg) { String[] arrayOfString = { "One", "Two", "Three", "Four" };   int i = 2; switch (i) { case 1: { … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on Switch Statement Java basic example
10,330 views

Goto labeled statement in Java example

Goto in for cycle Java example source code. MainClass.java public class MainClass { public static void main(String[] arg) { String[] arrayOfString = {"nothing", "Hello", "people" , "bye-bye", "hello", "world!", "end" };   OuterLoop: for (int i = 0;i<6; i++) { … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Goto labeled statement in Java example
7,207 views

break statement in Java Android example

break statement in Java Android basic example MainClass.java public class MainClass { public static void main(String[] arg) { String[] arrayOfString = {"nothing", "Hello", "people" , "bye-bye", "hello", "world!", "end" };   for (int i = 0; i < arrayOfString.length; i++) … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on break statement in Java Android example
35,614 views

If, else if, else statement Java Android example

if , else if, else statement with string as a switch statement in Java example source code. MainClass.java public class MainClass { public static void main(String[] arg) { String[] arrayOfString = {"nothing", "Hello", "people" , "bye-bye", "hello", "world!", "end" }; … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on If, else if, else statement Java Android example