Question: I have created a Deque in java and want to print out a string of integers, line by line, and from a text file. I

I have created a Deque in java and want to print out a string of integers, line by line, and from a text file. I tried setting my field "number" to an integer but it printed each number out in a singular row instead of line by line. I think I can get it to print line by line if I can convert the string into an integer, so where and how do I convert it to an integer in my code below? Also, if you know a way to set the field "number" as an integer, and print line by line without having to convert it then please show me how I would go about that. Your help is greatly appreciated.

I have created a Deque in java and want to print out

Deque my = new LinkedList(); File inputFile = new File ("file.txt"); Scanner insertion - new Scanner (inputFile) String number; while (insertion.hasNext()) number = insertion . nextLine(); my.offerFirst (number)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!