Java type conversion tutorial with examples contains Java examples of conversion between Strings, Numbers, Dates, Collections and other built-in API objects. One stop solution for all your “how do I convert from X to Y in Java” needs.
Primitive Data Types to String
- Convert any primitive type to String
- Convert int to String
- Convert long to String
- Convert float to String
- Convert double to String
- Convert byte to String
- Convert short to String
- Convert boolean to String
- Convert character to String
String to Primitive Data Types
- Convert String to any primitive
- Convert String to byte
- Convert String to short
- Convert String to int
- Convert String long
- Convert String to float
- Convert String to double
Wrapper Classes
- Convert primitive to wrapper objects
- Convert String to wrapper objects
- Convert Byte object to byte, short, int, long, float and double
- Convert Short object to byte, short, int, long, float and double
- Convert Integer object to byte, short, int, long, float and double
- Convert Long object to byte, short, int, long, float and double
- Convert Float object to byte, short, int, long, float and double
- Convert Double object to byte, short, int, long, float and double
String
- Convert stack trace to String
- Convert String array to String
- Convert String to String array
- Convert String to byte array
- Convert byte array to String
- Convert String to uppercase, Convert String to lowercase
- Convert String to ArrayList
- Convert int array to String
- Convert first character to uppercase
- Convert first character to lowercase
- Convert String to title case
Array
- Convert String array to List (Convert String array to ArrayList, LinkedList)
- Convert List (ArrayList, LinkedList) to Array
- Convert String to character array, character array to String
- Convert array to Set (Convert array to HashSet)
- Convert Set to array (Convert HashSet to Array)
- Convert array to LinkedHashSet
- Convert LinkedHashSet to array
Collections
- Convert HashMap to TreeMap
- Convert List to String (Convert ArrayList, LinkedList to String)
- Convert ArrayList<String> to String[] array
- Convert Map to List (Convert HashMap to ArrayList)
- Convert List to Map (Convert List to HashMap)
- Convert List to Set (Convert ArrayList to HashSet, Convert ArrayList to TreeSet)
- Convert comma separated String to ArrayList
- Convert String or String array to HashMap (String to Map)
- Convert LinkedList to Array
- Convert Array to LinkedList
- Convert LinkedHashMap to List
- Convert ArrayList to LinkedHashMap
- Convert LinkedHashMap to two arrays
- Java Convert TreeSet to array
- Java Convert array to TreeSet
- Convert TreeSet to List (ArrayList or LinkedList)
- Convert HashSet to TreeSet in Java
- Convert comma separated string to HashSet in Java
- Convert Hashset to comma separated string in Java
- Convert HashSet to ArrayList in Java
- Convert ArrayList to HashSet in Java
- Convert LinkedHashSet to ArrayList
- Convert ArrayList to LinkedHashSet
- Convert an array to Vector
- Convert Vector to an array
- Convert Vector to ArrayList and ArrayList to Vector
If you are looking for any specific Java conversion which is not covered in this type conversion tutorial, please let me know by leaving a comment in the comments section below.