SLIP 13 Q 1
SAVE CODE AS "arrayList.java"
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class arrayList {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.print("enter limit of array : ");
int num=sc.nextInt();
ArrayList<String> alist=new ArrayList<>(num);
for(int i=0;i<num;i++){
System.out.println("Enter "+i+" Element of ArrayList :");
String elmt=sc.next();
alist.add(elmt);
}
sc.close();
System.out.println("Orignal list :"+alist);
Collections.reverse(alist);
System.out.println("Reverse of a ArrayList is :"+alist);
}
}
Write a java program that asks the user name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters. For example, if the user's name is Raj, then the program should respond "Hello, RAJ, nice to meet you!".
ReplyDelete