The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to Convert Array to String in Java with Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to Convert Array to String in Java with Example Posted: Sep 18, 2014 9:15 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to Convert Array to String in Java with Example
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
Array and String are very closely related, not with anything else but with popularity. Many times we need to convert an array to String or create a array from String, but unfortunately there is no direct way of doing this in Java. Though you can convert array to String by simply calling their toString() method, you will not get any meaningful value.  If you convert an integer array to String, you will get something like I@4fee225 due to default implementation of toString() method form java.lang.Object class. First I shows the type of the array and content after @ is hash code value in hexadecimal. How valuable that is? This is not what I want to see, I was interested on contents rather than hashcode. Fortunately Java provides a utility class called java.util.Arrays, which provides several utility method for arrays in Java. For example, here we have method to sort array, search elements using binary search, fill array, methods to check if two arrays are equal or not, copy range of values from one array to another,  and much needed toString() and deepToString() method to convert both one dimensional and multi-dimensional array to String. These method provides content view of array, for example, when you convert an integer array {1, 2, 3, 4, 5, 6, 7} to String, you will get [1, 2, 3, 4, 5, 6, 7] instead of  [I@2ab6994f . In this article, we will see examples to convert different types of array to String e.g. int, char, byte, double, float, Object and String array itself.  We will also learn how to convert two dimensional array to String in Java.
Read more »

Read: How to Convert Array to String in Java with Example

Topic: IntelliJ IDEA 13.1.5 RC is Out Previous Topic   Next Topic Topic: Deployment Script vs. Rultor

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use