write a program to create an arraylist and listeterator.and
value should be enter through keyboard.

Answer Posted / magreal

public static void main(String[] args) {

String str;
List<String> l = new ArrayList();
int i=0;
boolean more = true;
do{
str = TextIO.getln();
l.add(str);
i++;
TextIO.putln("Add new item ? Y/N");
}while(TextIO.getlnBoolean());

for(String s: l){
TextIO.putln(s);
}
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is constructor and its types?

541


Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.

524


Can an abstract class be a final class?

531


What are the various access specifiers for java classes?

548


What are register variables what are the advantages?

452






What is stream api in java8?

540


What are different types of multitasking?

550


FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?

2643


What is yield () in java?

484


Differentiate between class and structure.

635


When will we use them?

601


What is a variable and constant?

550


What is use of set in java?

498


Explain method overloading?

574


What are the principle concepts of oops?

540