Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

toLowerCase Locale toUperCase Locale Java Android


AD MOB


String s = "AbcČ";
String s2 = s.toLowerCase(new Locale("cs_CZ")); // Czech Republic
String s3 = s.toLowerCase(new Locale("de_DE")); // Germany

//
en_US
en_GB
ar_EG
be_BY
bg_BG
ca_ES
cs_CZ
da_DK
de_DE

397LW NO topic_id




AD

Další témata ....(Topics)


17

double in Java example for Android development | double-in-java-example-for-android-development


Java double is 64 bit double precision type used when fractional
precision calculation is required.

Java double je datový typ (reálné číslo) o velikosti 64 bitů. Používá se například pro přesný výsledek po dělení za desetinnou tečkou. Pokud nepotřebuje tak veliké číslo použijte raději typ float, šetříte tím paměť mobilního telefonu.


		// declaration and assignment of value  type double
		double x = 18.41785;
		//print formated  value
		System.out.printf("The value of x is %.3f%n", x); // 18.418
                
                // declaring more variables in single statement
                double d1 = 12.4, d2 = 564.5, d3 = 14.589;

		// double range of value
		System.out.println(Double.MIN_VALUE); // 4.9E-324
		System.out.println(Double.MAX_VALUE); // 1.7976931348623157E308

		// is NaN  Not-a-Number
		double f = (double) Math.sqrt(-15);
		boolean bNaN = Double.isNaN(f);
		System.out.print(bNaN); // true
		
                // check if a string is a valid number in Java example
                // convert string to double Java example
		String sD = "12.8";
		double dParse = Double.parseDouble(sD);

	       // convert strings to numbers
	      String sDl = "15.48";
	      double dFromString = (Double.valueOf(sDl)).doubleValue();

// format double, float or long value to string
	DecimalFormat formatter = new DecimalFormat(".##");
	String s = formatter.format(-.5678);             // -0.57
// .###  -0.568
// .#### -0.5678
// .000000  -.567800

// -123.456
// .##  -123.46
// #.##  -123.46

// #E0  -.1E3
// ##E0  -1.2E2
//###E0  -123E0

// double to string in Java example code
Double dObj = new Double(68.5);
String str = dObj.toString();
// else 
Double dS = 11.6;
String sdouble = dS.toString();

// compare two double variables
	      Double dComp1 = 4.3;
	      if(dComp1.equals(4.3))
	  		System.out.print("true");

	// compares the two specified double values in Java example
	// int i =	compare(double d1, double d2);
	    int i =	Double.compare(11.5, 11.7); // -1 first < second
	    // 0 first == second
	    // 1 first > second
	    System.out.print(i);


88

Map TreeMap key value pair sort by value Java Android example | map-treemap-key-value-pair-sort-by-value-java-android-example


Map TreeMap sorted by value Java Android example.

MainClass.java


import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;

public class MainClass {
	public static void main(String[] arg) {

		// english;germany dictionary
		String[] arrayOfString = { "one;eine", "two;zwei", "three;drei",
				"four;vier" };

		Map<String, String> map = new TreeMap<String, String>();

		for (String s : arrayOfString) {
			String[] array = s.split(";");
			String sKey = "", sValue = "";
			if (array.length > 1) {
				sKey = array[0];
				sValue = array[1];
				map.put(sKey, sValue);
			}
		}
		for (Entry<String, String> entry: mapSortedByValues(map)) {
		    System.out.println(entry.getKey() + " = " + entry.getValue());
		}
	}

	static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> mapSortedByValues(
			Map<K, V> map) {
		SortedSet<Map.Entry<K, V>> sortedSetOfEntries = new TreeSet<Map.Entry<K, V>>(
				new Comparator<Map.Entry<K, V>>() {
					@Override
					public int compare(Map.Entry<K, V> entry_1, Map.Entry<K, V> entry_2) {
						int res = entry_1.getValue().compareTo(entry_2.getValue());
						return res != 0 ? res : 1; 
						// return entry_1.getValue().compareTo(entry_2.getValue());							
					}
				});
		sortedSetOfEntries.addAll(map.entrySet());
		return sortedSetOfEntries;
	}
}
/*
three = drei
one = eine
four = vier
two = zwei
 */

393

Unchecked call to add(E) as a member of raw type java.util.List | unchecked-call-to-adde-as-a-member-of-raw-type-java-util-list



// warnning
private List list = new ArrayList();

// ok /put type of added object
private List<String> list = new ArrayList<String>();
323

Eclipse update failed folder in use | eclipse-update-failed-folder-in-use


Failed to rename directory ....
If using for update Android SDK manager,
try close Eclipse if is open.
Or change security settings of the folder which have problem.
Or disable antivirus for a moment.
86

Map TreeMap key value pair add put get pair by key Java Android example | map-treemap-key-value-pair-add-put-get-pair-by-key-java-android-example


Map TreeMap add key value pair get find pair by key Java Android example.

MainClass.java

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", "three;drei" };

		Map<String, String> map = new TreeMap<String, String>();
	    
		for(String s: arrayOfString){
	    	String[] array = s.split(";");
	    	String sKey ="", sValue="";
	    	if(array.length > 1){
	    	sKey = array[0]; sValue = array[1];
	    		map.put(sKey, sValue);
	    	}
	    }

       // check if key exists 	    
	   if( map.containsKey("two")){
		System.out.print("two = " + map.get("two"));
	   }
	}
}
/*
two = zwei
 */



Editace: 2013-11-10 22:00:41
Počet článků v kategorii: 397
Url:tolowercase-locale-toupercase-locale-java-android

AD
11 Share
Share
Tweet