Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By JosAH

Thread: Query regarding retrieving data from linked list

  1. #1
    Join Date
    Jul 2016
    Posts
    2
    Rep Power
    0

    Default Query regarding retrieving data from linked list

    Hello fellow coders,

    I am not sure if this question is appropriate in this forum. This is data structure related question.

    Please forgive me if this post is not appropriate.

    Singly Linked List

    Here are the assumption.

    • The pointer is pointing on the last node.
    • The getNext() method retrieves the next node of the linked list. so assuming the pointer is pointing towards the last node lastnode.getNext() should retrieve NULL value.



    I'm curious what value will be retrived if the stament is lastnode.getNext().getNext().


    Please help me out!!

    Thanks in advance

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Query regarding retrieving data from linked list

    What you get is a NullPointerException; no more, no less ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Join Date
    Jul 2016
    Posts
    2
    Rep Power
    0

    Default Re: Query regarding retrieving data from linked list

    Thank you so much :)

Similar Threads

  1. Replies: 0
    Last Post: 09-25-2012, 04:07 AM
  2. Spreadsheet data - linked list or hashmap
    By j919 in forum New To Java
    Replies: 2
    Last Post: 02-19-2011, 07:20 PM
  3. Storing Mutiple Classes/Data Types in a Linked List
    By Chronoattica in forum New To Java
    Replies: 7
    Last Post: 12-28-2010, 10:03 PM
  4. Replies: 0
    Last Post: 03-31-2009, 04:52 PM
  5. Doubly-linked list with data structure
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 10:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •