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 4 of 4

Thread: Hey! can anyone help me . i cant find an error (beginner)

Threaded View

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Hey! can anyone help me with array of object . i cant find an error (beginner)

    hi, i m receiving error

    Please help me. and do tell me where i was wrong
    Thank you in advance

    Welcome to National Database
    Exception in thread "main" java.lang.NullPointerException
    at general.main(general.java:46)
    import java.util.Scanner;
    public class general {
     
    	String name;
    	String fname;
    	int dob;
    	char sex;
    	public general()
    	{
    		this("no","no",0,'n');
    	}
     
    	public general(String string, String string2, int i, char c) {
    		// TODO Auto-generated constructor stub
    	}
     
    	protected void addgeninfo()
    	{
    		Scanner inp = new Scanner(System.in);
     
    		System.out.println("Please Enter your name:");
    		name=inp.next();
     
    		System.out.println("Please Enter your Father's name:");
    		fname=inp.next();
     
    		System.out.println("Please Enter your dob(format:DDMMYYYY):");
    		dob=inp.nextInt();
     
    		String temp;
    		System.out.println("Please Enter your sex(m/f):");
    		temp=inp.next();
    		sex =temp.charAt(0);
     
    	}
     
    	public static void main(String[] asgc)
    	{
    		int totnationals=10;
    		System.out.println("Welcome to National Database");
    		general nationals[] = new general[totnationals];
     
     
    		for( int i =0; i <10; i++)
    		{
    			nationals[i].addgeninfo();
    		}
     
     
    	}
    }
    Last edited by fredsilvester93; July 18th, 2012 at 07:54 PM.


Similar Threads

  1. Cannot find Error in Beginner code!
    By bankoscarpa in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 2nd, 2012, 08:44 PM
  2. Please Help me Find the Error
    By jugalrockz in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 18th, 2012, 02:31 AM
  3. help to find the error of coding
    By arunjib in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 27th, 2011, 11:28 AM
  4. can any one plz find the error.
    By shalini_sns in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 23rd, 2011, 05:26 PM
  5. Need help, cannot find error
    By Imeri0n in forum What's Wrong With My Code?
    Replies: 13
    Last Post: December 5th, 2010, 05:26 PM