<?xml version="1.0" encoding="UTF-16"?>
<snippets>
<category filters="*" id="category_1171646324953" initial_state="0" label="Java Type Conversions" largeicon="" smallicon="">
<description/>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646697203" label="To catch illegal number conversion" largeicon="" smallicon="">
<description><![CDATA[Note: to catch illegal number conversion, try using the try/catch mechanism]]></description>
<content><![CDATA[try{
i = Integer.parseInt(aString);
}
catch(NumberFormatException e) {
...
}]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646672531" label="boolean to integer" largeicon="" smallicon="">
<description><![CDATA[i = (b)?1:0;]]></description>
<content><![CDATA[i = (b)?1:0;]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646659843" label="integer to boolean" largeicon="" smallicon="">
<description><![CDATA[b = (i != 0);]]></description>
<content><![CDATA[b = (i != 0);]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646639890" label="To extract ASCII codes from a string" largeicon="" smallicon="">
<description><![CDATA[String test = "ABCD";]]></description>
<content><![CDATA[String test = "ABCD";
for ( int i = 0; i < test.length(); ++i ) {
char c = test.charAt( i );
int j = (int) c;
System.out.println(j);
}]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646618406" label="integer to ASCII code (byte)" largeicon="" smallicon="">
<description><![CDATA[char c = 'A';]]></description>
<content><![CDATA[char c = 'A';
int i = (int) c; // i == 65 DECIMAL]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646603062" label="ASCII code to String" largeicon="" smallicon="">
<description/>
<content><![CDATA[ int i = 64;
String aChar = new Character((Char)i).toString();]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646578781" label="hexadecimal (String) to integer" largeicon="" smallicon="">
<description/>
<content><![CDATA[int i = Integer.valueOf("B8DA3", 16).intValue();
//or
//int i = Integer.parseInt("B8DA3", 16); ]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646561031" label="decimal to hexadecimal" largeicon="" smallicon="">
<description/>
<content><![CDATA[ int i = 42;
String hexstr = Integer.toString(i, 16);
or
String hexstr = Integer.toHexString(i);
or (with leading zeroes and uppercase)
public class Hex {
public static void main(String args[]){
int i = 42;
System.out.print
(Integer.toHexString( 0x10000 | i).substring(1).toUpperCase());
}
}]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646545531" label="decimal to binary" largeicon="" smallicon="">
<description><![CDATA[int i = 42;]]></description>
<content><![CDATA[int i = 42;
String bin = Integer.toBinaryString(i);]]></content>
</item>
<item category="category_1171646324953" class="" editorclass="" id="item_1171646533203" label="String to float" largeicon="" smallicon="">
<description><![CDATA[Float f = Float.valueOf(str).floatValue();]]></description>
<content><![CDATA[Float f = Float.valueOf(str).floatValue();]]></content>
</item>
<item category="ca�