please correct this program

please correct this program

import java.util.Scanner; public class Nam {

    public static void main (String arg[])
     {

        String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu","Banu"};
        System.out.println("Enter any character");
        Scanner scanobj=new Scanner(System.in);
        String st=scanobj.next();
        char ch=st.charAt(0);

        if(name[0].charAt(0)==st.charAt(0))
        {

            System.out.println("List of names");
        }
            else{ 
                System.out.println("Invalid");
        } 
    }

}

View Answers

February 11, 2012 at 2:44 PM

import java.util.*; 

public class Nam{

    public static void main (String arg[]){
        String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu","Banu"};
        System.out.println("Enter any character");
        Scanner scanobj=new Scanner(System.in);
        ArrayList list=new ArrayList();
        for(int i=0;i<name.length;i++){
            list.add(name[i].substring(0,1));
        }
        String st=scanobj.next();
        String sub=st.substring(0,1);
           if(list.contains(sub)){
               for(int i=0;i<name.length;i++){
                   if(list.get(i).toString().equals(sub)){
                     System.out.println(name[i]);
                   }
               }
           }
           else{ 
            System.out.println("Invalid");
           }
    }
}









Related Tutorials/Questions & Answers:
please correct this program
please correct this program  import java.util.Scanner; public class Nam { public static void main (String arg[]) { String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
Advertisements
C Program....PLEASE HELP
C Program....PLEASE HELP  For this assignment, you are to write a program that calculates points along a rhodonea curve, a.k.a. a mathematical rose..., and pointers. I am lost and need a little help starting please *int fillArray
please explain this program
please explain this program  public class MainClass { public static void main(String[] args) { System.out.println("Java
please solve this program
please solve this program  Build a package EMPPACK that contains one stored function Validatesal() and two stored procedures Insertemp() and Getempdetails().The Insert_emp() procedure inserts a particular employee
Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program... of n numbers? Develop a program that accepts the area of a square and will calculate its perimeter. Develop the program calculateCylinderVolume., which accepts
Java Program(Please reply asap)
Java Program(Please reply asap)  Find out the ways in which numbers can be added to get the same result Example:- 10 1+9=10 1+2+3+4=10 1+9=10
Please explain me the flow of this program..
Please explain me the flow of this program..  // Substring replacement. class StringReplace { public static void main(String args[]) { String org = "This is a test. This is, too."; String search
please explain me the flow of this program
please explain me the flow of this program  class Bticket extends Thread { Object train,comp; Bticket(Object train,Object comp){ this.train=train; this.comp=comp; } public void run(){ synchronized
please tell the reason for java.lang.ArrayIndexOutOfBoundsException: in program
please tell the reason for java.lang.ArrayIndexOutOfBoundsException: in program  public class Test { public static void show(int x[][],int y[][]){ int rows = x.length; int columns = y.length
please give me an idea to develop a program for this question?
please give me an idea to develop a program for this question?  How to enter a text or number from keyboard without using InputStreamReader method in java
please help me in coding this given program
are the prime numbers in ascending order write a program to find the nth term in this series. (i m unable to code this program..please provide solution...please help me in coding this given program  consider the below
please help me in coding this given program
are the prime numbers in ascending order write a program to find the nth term in this series. (i m unable to code this program..please provide solution...please help me in coding this given program  consider the below
please help me for this program - Java Beginners
please help me for this program   Write a program that asks the user for a starting value and an ending value and then writes all the integers (inclusive) between those two values. Enter Start: 10 Enter End: 14 10
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Please write code for this program in java and Explain it ? pl'sssssssss
Please write code for this program in java and Explain it ? pl'sssssssss  Question: We are given an array of 2n integers wherein each pair...;  wow i got also same program. ok leave it. in this program they are passing
please tell me the flow of execution of this program
please tell me the flow of execution of this program  class Test{ int x; Test(int x){ this.x=x; } static void access(){ System.out.println("x= "+x); }} class Static{ public static void main(String ar[]){ Test obj=new Test(55
please help me in a java program !! - Java Beginners
please help me in a java program !!  the porgram should use...://en.wikipedia.org/wiki/Kosaraju_algorithm) there are 4 classes in my program : Vertex... and run the program" i still need to modify the method kosaraju in the class Graph
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me   Hi have develop the jsp to populate... filed?. Please help me Thanks
Please provide the java code for the given program.
Please provide the java code for the given program.   We need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc..,   
please give me a java program for the following question
please give me a java program for the following question  Write a java program that displays multiple frames : Step 1: Design a frame with three buttons: ?Fruit?, ?Bird? and ?Animal? Step 2: On clicking ?Fruit? button
please eslain me the flow of execution of this program
please eslain me the flow of execution of this program  class Producer extends Thread { StringBuffer sb; boolean dataprodover = false; Producer(){ sb = new StringBuffer(); } public void run(){ for(int i=1;i<=10;i++){ try
beginner need help with online ordering program please
beginner need help with online ordering program please  I have created a program for an online ordering system and now have to add error handling and a few other things my teacher doesn't teach well is there a template I can go
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
Insertion sort program find calendar to array value 1000,5000,10000  program find calendar for insertion sort in jfram to array 1000
how can i write this program ?please suggest me
how can i write this program ?please suggest me  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Easy Counting Java Program...Please Help? - Java Beginners
Easy Counting Java Program...Please Help?  As I said, I am a beginner at Java. I came across this problem that Im sure uses java. Could you please... someone PLEASE give me this code? I would really love to know this program! THANK
Getting Exception on UseDefinedException sample program - Please help me how to resolve
Getting Exception on UseDefinedException sample program - Please help me how to resolve  class UseDefinedException extends Exception{ String msg...(test1.java:34) what is MyException and how it called ..please explain
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
java program.. the question is scary ...please help - Java Beginners
java program.. the question is scary ...please help  Modify the Lexer..., etc. 4. Print each token with line number READLINE: program { int i int j program left: 0 right: 6 line: 1 { left: 8 right: 8: line: 1 int
why and where we use setter and getter methods in java, please give me one example program.....
why and where we use setter and getter methods in java, please give me one example program.....  why and where we use setter and getter methods in java, please give me one example program
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started..., then the correct result will be displayed. The result canā??t be edited
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.  import java.io.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.  HERES TEH QUESTION - I AM MISSING SOME..., ADDRESS AND ADMISSIONS CLASS PLEASE HELP!!! Write a Java program which
ModuleNotFoundError: No module named 'correct-horse'
ModuleNotFoundError: No module named 'correct-horse'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'correct-horse' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'reynir-correct'
ModuleNotFoundError: No module named 'reynir-correct'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'reynir-correct' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'correct-horse'
ModuleNotFoundError: No module named 'correct-horse'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'correct-horse' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'correct_pycountry'
ModuleNotFoundError: No module named 'correct_pycountry'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'correct_pycountry' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'correct_pycountry'
ModuleNotFoundError: No module named 'correct_pycountry'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'correct_pycountry' How to remove the ModuleNotFoundError: No module
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started..., then the correct result will be displayed. The result canā??t be edited.   import
Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m; xMethod(3. 4); } public static int xMethod(int n) { if (n > 0) return 1
correct the sql error
correct the sql error  i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do...(null,"Please enter the Student ID to Search","Error",0); } else { try
Free Java Is it correct?
Free Java Is it correct?  Hi, Is Java free? If yes then where I can download? Thanks   Hi, You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html Thanks
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks
how can create pop() method in this program ,Or how can delete image in it when i press pop button in runtime ??? please help me ...
how can create pop() method in this program ,Or how can delete image in it when i press pop button in runtime ??? please help me ...   // these image that put in program must be in the same folder that saved the program
Can you correct this codes?
Can you correct this codes?  Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4 at searchcon.(searchcon.java:39) at search.initComponents(search.java:41) at search.(search.java:7) at payroll
program
program  no i want a program that shows how merge sort algorithm... in rectangles or circles wat ever it may be. the theme of program is to show algorithm... circles etc., please help in making
java please please help
java please please help  Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static String a="{a=100;b=200;c=300}"; public static void main(String args
Program
Program  hey please help me ... How can write multiple choice question paper using radio button.After submit calculate marks and display our marks... is allowed to choose the correct option from multiple choices. The result

Ads