Home Answers Viewqa Java-Beginners null pointer exceptions

 
 


sushil kumar
null pointer exceptions
0 Answer(s)      6 months and 12 days ago
Posted in : Java Beginners

import java.util.*; public class employee { static int ch; static int emp[]; String name; int id,age; float sal; void insert() { employee[] emp=new employee[90];

    Scanner r=new Scanner(System.in);
    System.out.println("Enter the no of employees");
    int n=r.nextInt();
    for(int i=0;i<n;i++)
    {
        System.out.println("Enter details of employee"+(i+1));
        emp[i].setdata();
    }
    System.out.println("---------------------details of employee-----------------------\n");
    System.out.println("name \t id \t age \t salary");



    for(int i=0;i<n;i++)

    {

        emp[i].getdata();
    }

}
private void setdata() {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the name of employees");
    name=sc.nextLine();
    System.out.println("Enter the id of employees");
    id=sc.nextInt();
    System.out.println("Enter the id of employees");
    age=sc.nextInt();
    System.out.println("Enter the salary of employees");
    sal=sc.nextFloat();
}
private void getdata() {

    System.out.println(name+"\t"+id+"\t"+age+"\t"+sal);
}

void search()
{
    System.out.println("searched");
}
void delete()
{
    System.out.println("deleted");
}
void edit()
{
    System.out.println("edited");
}
public static void main(String[] args) {
    // TODO Auto-generated method stub
    employee e=new employee();
    Scanner s=new Scanner(System.in);
    System.out.println("Enter your Choice:");
    System.out.println("1.Insert\n2.Search\n3.Delete\n4.Edit");
    System.out.println("Enter your Choice:");
    ch=s.nextInt();
    switch(ch)
    {
    case 1:
        e.insert();
        break;
    case 2:
        e.search();
        break;
    case 3:
        e.delete();
        break;
    case 4:
        e.edit();
        break;
    case 5:
        System.out.println("Wrong choice entered");

    }

}

} Exception in thread "main" java.lang.NullPointerException at employee.insert(employee.java:19) at employee.main(employee.java:73) please sort it out

View Answers









Related Pages:
null pointer exceptions
null pointer exceptions  import java.util.*; public class employee { static int ch; static int emp[]; String name; int id,age; float sal; void insert() { employee[] emp=new employee[90]; Scanner r
Java null pointer exception handling
Java null pointer exception handling   What... of modifying null value or obtaing a null value in an arrray. To handle null pointer... helpful in handling null exceptions. Example of NullPointerException: try
Null Pointer Exception
Null Pointer Exception        Null pointer exceptions are the most common run time .... Normally, the latter one is more common. Rule for Debugging Null Pointer
null pointer
null pointer  dear sir , what is mean by null pointer in c
null pointer exception in java
null pointer exception in java  What is null pointer exception in Java and when it occurs? Show it with an example.Thanks!   Java Null Pointer Exception
Httpservletresponse null pointer exception.
Httpservletresponse null pointer exception.  What is Httpservletresponse null pointer exception?   NullPointerException occurs when we try to implement an application without referencing the object and allocating
Null Pointer Exception
Null Pointer Exception  whis is the Null Pointer Exception in java? or define Null Pointer Exception with exp?   NullPointerException occurs, when you try to implement an application without referencing the object
Java null pointer exception
Java null pointer exception  Hi I've made an array of Book objects that I made, the array is called library and it can hold 100 books, but currently...]!=null){ if(strfield.contains(param)){ result+=library[counter
NUll POINTER EXCEPTION
NUll POINTER EXCEPTION  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException... of code i m getting null pointer Exception. can some one please explain what
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null pointer error sir please help me my code are given below compilatation class
null pointer error
null pointer error  Respected sir there is a problem in this code when i add any new record in ms access data base from my code, it gives only null pointer error sir please help me my code are given below compilatation class
Null Pointer Exception - Java Beginners
Null Pointer Exception  How Can I Handle NullPoiniterException without using try/catch mechanism
Null pointer exception in hibernate - Hibernate
Null pointer exception in hibernate  Hi i am getting null pointer exception.while running the program in hibernate... is compiled successfully but while running the program i am getting null ponter
Java Exception - Handle Exceptions in Java
; Null Pointer Exception Null pointer exceptions are the most... Java Exception - Handle Exceptions in Java       Exceptions in Java
null pointer exception cannot be removed
null pointer exception cannot be removed  class list { public... Exception nothing; public int r; public list() { this(null,null,0); } public list(String e,int i) { this.elem = e; this.next = null
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Why the null Pointer exception is comming? - Java Beginners
Why the null Pointer exception is comming?  My code is given below...")); String []oldOne = null; String[]newOne; int i = 0...}; String line; String line1; String[] tokens = null
Null pointer exception error in Jsp - JSP-Servlet
Null pointer exception error in Jsp  Hi i write a login page. when i validate the login value then the nullpointer exception error is occured. my..." attributes in the input tag So id,userpwd gives null pointer exception
Null pointer exception error in Jsp - JSP-Servlet
Null pointer exception error in Jsp  Expert:Majid Hi i write a login page. when i validate the login value then the nullpointer exception error..." attributes in the input tag So id,userpwd gives null pointer exception. Thanks
Handle Null Pointer Exception while text file upload
Handle Null Pointer Exception while text file upload  I want the code for handling null pointer exception in jsp page. That is I need an error page for null pointer exception. The cause for null pointer exception is while
when do we get null pointer exception in java
when do we get null pointer exception in java  can anybody explain me abt null pointer exception? like in wt situation do v get NPE? Are these 2 strings same? String str; String str=null
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
Clicking F5 and reentering value throws Null pointer exception
Clicking F5 and reentering value throws Null pointer exception  Hi, My page performs search operation.Normally when i enter a value and click... refresh my page and enter any value it is throwing Null pointer exception.can
pointer
pointer  CONSTRTUCT A STRUCTURE FOR EMPLOYEE RECORD THAT CONTAINS A PERSON'S NAME, AGE, EMPLOYEE AND SALARY.WRITE A STATEMENT THAT DECLARES A VARIABLE empInfo and a pointer emPtr of type EMPLOYEE.then use the pointer to display
exceptions
exceptions  why we get compiletime exceptions(checkedExeption)? forEg:IOException,servletException
Exceptions - JSP-Servlet
java.lang.NumberFormatException: null Even i entered some values for this text box it returns the null exception. Please send me the answer. Thankz
check null exception java
check null exception java  check null exception java - How to check the null exception on Java?   The null pointer exception in java occurs... on it. See the example null pointer exception
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting... { private static ConnectionPool pool = null; private static DataSource dataSource = null; private ConnectionPool
Catching Normal Exceptions
Catching Normal Exceptions       The exceptions that are generated by methods are referred to as normal exceptions.  We have already learned that to catch an exception
how to move pointer in Textfield to newline
how to move pointer in Textfield to newline  consider my case...); add(l4); add(tf1); add(tf2); add(tf3); setSize(400,600); setLayout(null...); setLayout(null); setVisible(true
What are Chained Exceptions?
What are Chained Exceptions in Java?   ... provides new functionality for chaining exceptions. Exception chaining (also... exception is caused by the first exception. Therefore chained exceptions help
Catching and Handling Exceptions
Java Catching and Handling Exceptions       The various keywords for handling exceptions... the exceptions. These are try, catch and finally clause. The mechanism to catch
Catching Exceptions in GUI Code - Java Tutorials
In this section, we will discuss how to catch uncaught exceptions in GUI. Lets see... at java.awt.EventDispatchThread.run After printing the above exceptions... and attach the dialog to that, instead * of always attaching it to null
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello, Yes, a pointer is a variable
is there is pointer in java or not??
is there is pointer in java or not??  is there is pointer in java or not plz tell me this with brief?? thank you
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
Exceptions - More
Java NotesExceptions - More Exceptions | Exception Usage | Exceptions - More Kinds of Exceptions There are many exceptions, but they can be put into two groups: checked exceptions and unchecked exceptions
Function pointer in c
Function pointer in c  What is the difference between function call with function pointer and without function pointer(normal function call
c-language pointer functions
c-language pointer functions  what is the execution process of character pointer functions with example
Null value when i set interface object in form controller - Spring
got NULL pointer exception ... please guide me if any one know ...it is very...Null value when i set interface object in form controller   Hi all, i am very new about spring and hibernate. i got null value when i set
incomplete pointer type NSMutableDictionary
incomplete pointer type NSMutableDictionary  My iphone app is throwing the "incomplete pointer type NSMutableDictionary" issue on running the iphone app. What is this issue and how can i remove it. NSMutableDictionary *dict
how to deal with exceptions in servlet
how to deal with exceptions in servlet  plz give me the reply
Exceptions
Java NotesExceptions Exceptions | Exception Usage | Exceptions - More... that will catch it. You shouldn't try to catch most exceptions, but you should catch all exceptions that are caused by events which you have no control
Pointer in java - JSP-Servlet
Pointer in java   Hello ! All i know that java has no pointer type facility. but i have a problem to related pointer. Actually m using a dll and in that dll there is function that rec add of byte type variables address
Exceptions in java
Exceptions in java       Exceptions are used for handing errors and other exceptional events in Java programming language.Exception: Exceptions are abnormal or special conditions

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.