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.


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

Results 1 to 2 of 2

Thread: Exception in my code:Exception in thread "main" java.lang.NullPointerException

  1. #1
    Junior Member
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Default Exception in my code:Exception in thread "main" java.lang.NullPointerException

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    class check
    public static void main(String args[]) throws IOException,Exception,ParseException
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int testCases =Integer.parseInt(br.readLine());
    Date[] enterTime1=new Date[4];
    for(int i=0;i<testCases;i++)

    String s=br.readLine();
    String s1=br.readLine();

    String [] splitStartTime=s.split("-");
    String [] splitStopTime=s1.split("-");

    boolean check=isOverlapping(enterTime1[0],enterTime1[1],enterTime1[2],enterTime1[3]);
    System.out.println("will need a moderator");
    System.out.println("Who need a moderator");
    public static boolean isOverlapping(Date start1, Date end1, Date start2, Date end2)
    return start1.before(end2) && start2.before(end1) && start1.before(end1);
    public static Date changeTime(String time) throws ParseException
    DateFormat sdf1 = new SimpleDateFormat("hh:mm");
    Date enterTime= sdf1.parse(time);
    return enterTime;

    Please help where i am going wrong

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: Exception in my code:Exception in thread "main" java.lang.NullPointerException

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly per the above link. Also, when you're asking for help with an error, post it exactly and completely from what you're seeing. Copy the whole thing, the error and stack trace, and post it.

    --- Update ---

    Thread moved per OP request.

    Please edit your original post or add a new post that uses code tags and includes the full error message.

Similar Threads

  1. "Exception in thread "main" java.lang.NullPointerException" help?
    By redstripes in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 28th, 2014, 08:59 AM
  2. [SOLVED] error in my code(Exception in thread "main" java.lang.NullPointerException)
    By barhom in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 27th, 2013, 06:42 AM
  3. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  4. Replies: 5
    Last Post: December 9th, 2012, 02:25 PM
  5. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM