Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: NULLeXCEPTION PROBLEM plz helppp

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation NULLeXCEPTION PROBLEM plz helppp

    import java.util.*;
    import java.io.*;
    class contacts
    {

    static int i=-1,j;
    static char a;
    static String[] name = new String[10];
    static String[] email = new String[10];
    static String[] mobile = new String[10];
    static String[] telno = new String[10];

    public static void main(String args[]) throws IOException
    {

    do
    {

    i++;
    Scanner ob = new Scanner(System.in);
    System.out.println("Enter Name");
    name[i]=ob.nextLine();
    System.out.println("Enter Email");
    email[i]=ob.nextLine();
    System.out.println("Enter MObile no");
    mobile[i]=ob.nextLine();
    System.out.println("Enter Tel no");
    telno[i]=ob.nextLine();

    ArrayList<String> contacts = new ArrayList<String>();
    contacts=new ArrayList<String>();
    contacts.add(name[i]);
    contacts.add(email[i]);
    contacts.add(mobile[i]);
    contacts.add(telno[i]);
    System.out.println(contacts);
    System.out.println("do u want to continue y/n");
    a=ob.nextLine().charAt(0);
    }while(a=='y');
    FileWriter f = new FileWriter("info.txt");
    for(j=0;j<name.length;j++)
    f.write(name[j]);
    for(j=0;j<email.length;j++)
    f.write(email[j]);
    for(j=0;j<mobile.length;j++)
    f.write(mobile[j]);
    for(j=0;j<telno.length;j++)
    f.write(telno[j]);
    f.close();

    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,320
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: NULLeXCEPTION PROBLEM plz helppp

    Please post the full text of the error message.

    Also please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM
  2. MergeSort not working Helppp please :(
    By colombianita2089 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 17th, 2010, 09:56 PM
  3. Problem in import com. in eclipse
    By java_cs in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 11th, 2009, 08:26 AM