Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

String in Queue

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Queue<String> queue = new LinkedList<>();
        System.out.println("Enter input:");
        String input = "";
        try (Scanner scan = new Scanner(System.in)) {
            while (scan.hasNextLine()
                    && (input = scan.nextLine()).length() != 0) {
                queue.add(input);
            }
        }
        System.out.printf("Queue: %s%n", queue);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #String #Queue
ADD COMMENT
Topic
Name
1+7 =