Write a java method named flipLines that accepts as its para

Write a java method named flipLines that accepts as its parameter a Scanner for an input file and that writes to the console the same file\'s contents with successive pairs of lines reversed in order.

Solution

public static void flipLines(Scanner input) {

while (input.hasNextLine()) {

String first = input.nextLine();

if (input.hasNextLine()) {

String second = input.nextLine();

System.out.println(second); }

System.out.println(first); } }

Write a java method named flipLines that accepts as its parameter a Scanner for an input file and that writes to the console the same file\'s contents with succ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site