I am trying to read a CSV file and then store it into an ArrayList. For each row, I'm trying to create a new Country class instance and add it to the list. However, it is giving me the following as the output: edu.uga.cs1302.quiz.Country@7c9bb6b8 edu.uga.cs1302.quiz.Country@441847 edu.uga.cs1302.quiz.Country@2621fba7 edu.uga.cs1302.quiz.Country@4fa6e7a1 edu.uga.cs1302.quiz.Country@6e29b69b edu.uga.cs1302.quiz.Country@4e0f0d39 edu.uga.cs1302.quiz.Country@67da3b9c edu.uga.cs1302.quiz.Country@1f394329 edu.uga.cs1302.quiz.Country@3c07b33b edu.uga.cs1302.quiz.Country@a570747 edu.uga.cs1302.quiz.Country@3ce7cb4a edu.uga.cs1302.quiz.Country@6912e7f4 edu.uga.cs1302.quiz.Country@680d0f86 edu.uga.cs1302.quiz.Country@5a5250ff edu.uga.cs1302.quiz.Country@58ed7d64 edu.uga.cs1302.quiz.Country@26be1cca edu.uga.cs1302.quiz.Country@26cf56a4 edu.uga.cs1302.quiz.Country@6ed22f2a edu.uga.cs1302.quiz.Country@5de769c9 edu.uga.cs1302.quiz.Country@b6966f3 edu.uga.cs1302.quiz.Country@574f6b4c edu.uga.cs1302.quiz.Country@289bb5f0 edu.uga.cs1302.quiz.Country@4ed4380b edu.uga.cs1302.quiz.Country@eca81dc edu.uga.cs1302.quiz.Country@22f38e42 edu.uga.cs1302.quiz.Country@57329bd9 edu.uga.cs1302.quiz.Country@3849e554 edu.uga.cs1302.quiz.Country@625747e0 edu.uga.cs1302.quiz.Country@5ce84476 edu.uga.cs1302.quiz.Country@1fc7e061 edu.uga.cs1302.quiz.Country@68d3c588 edu.uga.cs1302.quiz.Country@30e3e735 edu.uga.cs1302.quiz.Country@2eb6deab   I am trying to get the Output: Afghanistan,Asia Albania,Europe Algeria,Africa Andorra,Europe Angola,Africa Antigua and Barbuda,North America Argentina,South America Armenia,Europe Australia,Oceania Austria,Europe Azerbaijan,Europe Bahrain,Asia Bangladesh,Asia Barbados,North America Belarus,Europe   How do I fix this?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

I am trying to read a CSV file and then store it into an ArrayList. For each row, I'm trying to create a new Country class instance and add it to the list. However, it is giving me the following as the output:

edu.uga.cs1302.quiz.Country@7c9bb6b8

edu.uga.cs1302.quiz.Country@441847

edu.uga.cs1302.quiz.Country@2621fba7

edu.uga.cs1302.quiz.Country@4fa6e7a1

edu.uga.cs1302.quiz.Country@6e29b69b

edu.uga.cs1302.quiz.Country@4e0f0d39

edu.uga.cs1302.quiz.Country@67da3b9c

edu.uga.cs1302.quiz.Country@1f394329

edu.uga.cs1302.quiz.Country@3c07b33b

edu.uga.cs1302.quiz.Country@a570747

edu.uga.cs1302.quiz.Country@3ce7cb4a

edu.uga.cs1302.quiz.Country@6912e7f4

edu.uga.cs1302.quiz.Country@680d0f86

edu.uga.cs1302.quiz.Country@5a5250ff

edu.uga.cs1302.quiz.Country@58ed7d64

edu.uga.cs1302.quiz.Country@26be1cca

edu.uga.cs1302.quiz.Country@26cf56a4

edu.uga.cs1302.quiz.Country@6ed22f2a

edu.uga.cs1302.quiz.Country@5de769c9

edu.uga.cs1302.quiz.Country@b6966f3

edu.uga.cs1302.quiz.Country@574f6b4c

edu.uga.cs1302.quiz.Country@289bb5f0

edu.uga.cs1302.quiz.Country@4ed4380b

edu.uga.cs1302.quiz.Country@eca81dc

edu.uga.cs1302.quiz.Country@22f38e42

edu.uga.cs1302.quiz.Country@57329bd9

edu.uga.cs1302.quiz.Country@3849e554

edu.uga.cs1302.quiz.Country@625747e0

edu.uga.cs1302.quiz.Country@5ce84476

edu.uga.cs1302.quiz.Country@1fc7e061

edu.uga.cs1302.quiz.Country@68d3c588

edu.uga.cs1302.quiz.Country@30e3e735

edu.uga.cs1302.quiz.Country@2eb6deab

 

I am trying to get the Output:

Afghanistan,Asia

Albania,Europe

Algeria,Africa

Andorra,Europe

Angola,Africa

Antigua and Barbuda,North America

Argentina,South America

Armenia,Europe

Australia,Oceania

Austria,Europe

Azerbaijan,Europe

Bahrain,Asia

Bangladesh,Asia

Barbados,North America

Belarus,Europe

 

How do I fix this?

public static List<Country> readCSVFile() {
List list = new ArrayList<Country>();
try {
Reader in = new FileReader("/home/country_continent.csv");
Iterable<CSVRecord> records =
CSVFormat.DEFAULT.parse(in);
for (CSVRecord record : records) {
String country = record.get(0);
String continent = record.get(1);
Country data = new Country(country, continent);
list.add(data);
}
for (int i
0; i < list.size(); i++) {
System.out.println(list.get(i));
%D
} catch (IOException e) {
System.out.println(e);
}
return list;
}
Transcribed Image Text:public static List<Country> readCSVFile() { List list = new ArrayList<Country>(); try { Reader in = new FileReader("/home/country_continent.csv"); Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(in); for (CSVRecord record : records) { String country = record.get(0); String continent = record.get(1); Country data = new Country(country, continent); list.add(data); } for (int i 0; i < list.size(); i++) { System.out.println(list.get(i)); %D } catch (IOException e) { System.out.println(e); } return list; }
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY