Ask about java



Share on Google+Share on Google+

Ask about java
2 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners

Create a java program for add and remove the details of a person, which is not using by database, a simply java program. If possible, please wil it in switch case.

View Answers

July 29, 2011 at 5:38 PM

import java.util.ArrayList;
import java.util.Scanner;

class Person{
        String name;
        String address;
        String email;
        int contactNo;

        Person(String name,String address,String email,int contactNo){;
        public String getName(){
                return name;

        public String getAddress() {
                return address;

        public String getEmail() {
                return email;

        public int getContactNo() {
                return contactNo;

public class ArrayListEx {
  public static void main(String[] a) {
      Scanner input=new Scanner(;
                ArrayList<Person> list = new ArrayList<Person>();
                list.add(new Person("A","Delhi","[email protected]",11111));
                list.add(new Person("B","Mumbai","[email protected]",22222));
                list.add(new Person("C","Chennai","[email protected]",33333));
                list.add(new Person("D","Kolkata","[email protected]",44444));
                boolean exit=false;
                for(Person data: list){
                System.out.println(data.getName()+"\t "+data.getAddress()+"\t "+data.getEmail()+"\t "+data.getContactNo());
                System.out.println("1 Add Details");
                System.out.println("2 Exit");
                System.out.print("Enter your choice: ");
                int choice=input.nextInt();
                case 1:
                  System.out.print("Enter name: ");

                  System.out.print("Enter address: ");

                  System.out.print("Enter email: ");

                  System.out.print("Enter contactNo: ");
                  int contactNo=input.nextInt();

                  list.add(new Person(name,address,email,contactNo));

                  for(Person data: list){
                     System.out.println(data.getName()+"\t "+data.getAddress()+"\t "+data.getEmail()+"\t "+data.getContactNo());

                  case 2 :
                     System.out.println("Invalid Selection!");

August 1, 2011 at 8:40 AM

Very Thanks. It is useful to me. Thanks for ur reply.


Related Tutorials/Questions & Answers:
Ask about java
Ask about java  Create a java program for add and remove the details of a person, which is not using by database, a simply java program. If possible, please wil it in switch case
Ask about looping in database
Ask about looping in database  Good afternoon, I want to ask...=True,A2=True : code is the same data Rule and Heritage. I want to ask that how to read looping in field rights(if A1=false and A2 = True), use from java. i
Ask java count
Ask java count  Good morning, I have a case where there are tables... | Java 1 | 10 | | b002 | beginner java | 5 | | b003 | advanced java book | 26 | | b004 | MySQL 1
ask java - Date Calendar
but in java i found too but i can't to join in another frame. And i want to ask how...ask java  sory i'am wrong language. i want to ask to this forum how... information on Java visit to : Thanks  
ask - Java Beginners
ask   dear how to "print out" into a file ? regard suhadi  Hi friend, Please explain properly requirement. I am sending simple...:// Thanks. Amardeep
Ask Java Questions Online
Ask Java Questions Online       Now, it’s time to rejoice for the Java... Developer Company has just begun a new service ‘ask question online&rsquo
Ask make graph from i report and view to java Language Programming
Ask make graph from i report and view to java Language Programming  Dear sir, Please help me, i want to make a graph from mysql to i report and view to java. Please help me, give me example source code please. thank you
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at Thanks
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
About java
About java   how we insert our database data into the jTable in java or how we show database content into the JTable in java   Hi Friend, Try the following code: import*; import
about java
about java  how to get the value from the user like c, c++ program pls explain with example for me
Ask Servlet questions online
Ask Servlet questions online       Feel free to ask any question about servlets... kicked off a new service ‘ask questions’ to resolve your query
about JAVA - Java Beginners
about JAVA  i have to create a program that will sort the given... ERROR and ask the user again to enter the number of inputs. i don't know how to do that. Also, after executing the program i want to ask the user if they want
Ask Questions with Options
Ask Questions with Options using Java In this section, we are going to ask five questions one after the other with four options to test the user. For this, we have stored 5 questions, answers with four options into a list. The list
about J2EE. - Java Beginners
about J2EE.  I know only core Java ... what chapter I will be learn to know about J2EE
about jboss - Java Beginners
about jboss  can you please explain about to deploy,where the temp and lock is information about jboss to use in java message services(JMS
about JVM - Java Beginners
about JVM  Hello Rose team I want to ask that why JVM is platform dependent is it automatically installs whenever we install jdk or is it automatically installed whenever we install operating system on our machine
Ask for latest version for hibernate
Ask for latest version for hibernate  any new version for hibernate after 3.0, if yes can u give some exmp for latest version of hibernate
about java - Java Beginners
about java  hello, being a begineer in Java i would like know that as we read the value entered by user through cin>> in c++ how we did it with java.  Hi Friend, There are lot of ways to input data.You can use
About basics - Java Beginners
About basics  Why we are typing java program in text editor? Why we are running the java program in command prompt
about J2EE. - Java Beginners
about J2EE.  I know only core Java ... what chapter I will be learn to know about J2EE.  Hi Friend, Please visit the following link: Thanks
Ask date difference
Ask date difference  Hello, I have a problem about how to calculate date, the result from this code is not complete , this is my code . please help me. thank you public void a(){ String date1 = jTextField33.getText(); String
about c and java
about c and java   i need java and c language interview and objective questions with answers for the fresher.please provide to me   Please visit the following links: http
about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir...: Hope
about package - Java Beginners
about package  as i am programming a question based on creating own... in the root directory.In my system java is installed in c:\ibm\java142\bin how can i run...:// Hope
about enum - Java Beginners
about enum  hi all, please tell me about "enum" and explain with example. And its use in OOP. Thanks
about array in java
about array in java  speed of a vehicle is measured using the total time and the distance by using the equation given bellow speed(km/hour)=distance... Vehicle 02 = 5 hours Write a JAVA class to represent the Vehicle. The program should
about interface - Java Beginners
about interface  can anyone explain to me the implementation of the given line Set si=new HashSet(); Problem is that Set is an interface...://
About Java - Java Interview Questions
About Java  what is edition of java? versions of weblogic? what r the webserver applications used in your application
About Java
About Java This article is discussing about Java, which is a programming language developed by James Gosling at Sun Microsystems. Java now part of Oracle... about Java is listed below : Around 1.1 billions desktop runs Java. Every
about coding - Java Beginners
about coding  hello sir, I want to create session expair, when user is not enter anything in login page session wil expair after 10 min.if user enter its go to success page.plz send me full code about this. thanks
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java


Advertisement null