java


I want to display the element in an arraylist, not the hashcode


I am currently trying to display a csv file called "Haha2" using csv open in Java. Unfortunately when I print the arraylist I get the hashcode and not the numbers that are contained in the file.
I have tried the .get() method and the .toArray() and .toString methods but I am still only able to print out the hashcode.
Here's my code:
import au.com.bytecode.opencsv.*;
import java.io.*;
import java.util.*;
public class playlist{
public static void main (String args()) throws IOException {
CSVReader reader = new CSVReader(new FileReader("Haha2.asc"),';', '"',29);
List <String[]> data = new ArrayList <String[]>();
data = reader.readAll();
System.out.println(data);
}
}
Here is a one-liner which first converts the list to an array giving you an array-of-arrays and then calling Arrays.deepToString().
System.out.println(Arrays.deepToString(data.toArray()));
Either loop through your list and call Arrays.toString() on each of the array of Strings, or transform List<String[]> into List<List<String>>.
Use Arrays.toString():
for( String[] array : data ) {
System.out.println(Arrays.toString(data));
}
iterate over the List and than over the array:
for( String[] array : data ) {
for( String string : array ) {
System.out.println(string);
}
System.out.println("---");
}
for (String[] arr : data) {
System.out.println(java.util.Arrays.asList(arr));
System.out.println("...");
}

Related Links

Initialising an instance variable with a method from the class
JUnit before and test
Eclipse color themes - java and flex
Can you add multiple jars in a jar file and then launch that jar file
Websphere Portlet migration, missing parameter in DispatchAction
How much code should one put in a constructor?
Function pointers/delegates in Java?
Reference Groovy domain class from Java class using Eclipse?
What are the steps I need to take to add nice java code formatting to my blogger/blogspot blog? [closed]
Java graphic library for multicoloured text
Finding Memory Usage in Java
how to convert hex to byte for the following program?
Replace JBoss error page with Axis2 fault XML response
Using threads and recursion in Java to calculate Fibonacci numbers
Attach UncaughtExceptionHandler to a TimerTask
Anyone doing mainframe or AS/400 Batch processing with Java? [closed]

Categories

HOME
twitter
arduino-uno
pdf
deployment
pycharm
mfc
smarty
react-virtualized
include
fft
getelementsbytagname
razor
filtering
youtube-api-v3
awesome-wm
vifm
rascal
modx-revolution
qt-creator
etl
n-gram
remote-access
size
ibm-odm
telephony
foselasticabundle
ef-migrations
facebook-page
serilog
aurigma
reactive-cocoa
oracle-coherence
nas
web-sql
sox
wkwebview
extjs5
su
objectanimator
r-raster
yadcf
code-contracts
openoffice.org
atl
sequential
revolution-slider
devextreme
retina-display
automake
swift3.0.2
objectlistview
pdf-reactor
unixodbc
slick-3.0
sencha-touch-2.3
filepicker
zip4j
typescript1.8
domain-model
nsarray
media-player
capacity
linode
hittest
django-scheduler
webdriverjs
angular-strap
time-and-attendance
parallel-data-warehouse
wdf
google-feed-api
etsy
plottable.js
fputcsv
connect-by
angstrom-linux
php-internals
php-parse-error
asp.net5
wapiti
browser-link
uid
javax.sound.midi
r-tree
execute
intellij-14
atk4
tmuxinator
wireshark-dissector
kcachegrind
map-projections
ideamart
dundas
key-management
formatjs
website-monitoring
clicktag
typekit
asp.net-dynamic-data
xojo
project-planning
sgen
uitouch
resty-gwt
stxxl
farseer
commoncrypto
eventual-consistency
hamiltonian-cycle
amazon-appstore
custom-backend
locationlistener
inotifycollectionchanged
locate
h.323
rescale
backcolor
temporal-database
text-coloring
multiple-languages
paul-graham

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App