Remove the last element

Hello

I'm removing the last element in a LL individually. But it's not entry (method deleteFromTail) and also a message delete2 which I have not written anywhere in my print program... I don't have the code running on any other computer.

Javax.swing import. *;

Class StudNode {}

int id;

The name of the string;

Next StudNode;

StudNode (int id1, String name1) {}

ID = id1;

name = name1;

}

}

public class StudListDel2 {}

StudNode head, tail;

StudListDel2 () {}

head = tail = null;

}

Sub create4ElementList () {}

Add them to the queue

int id = 1;

int i = 0;

String name = "THIS" + id;

StudNode newNode;

newNode = new StudNode (id, name);

head = newNode;

tail = newNode;

for (i = 0; i < 4; ++ I) {}

ID ++;

name = "THIS" + id;

newNode = new StudNode (id, name);

tail. Next = newNode;

tail = newNode;

tail. Next.Next = null;

}

}

Sub display4List () {}

tail = head;

{while(tail!=null)}

JOptionPane.showMessageDialog (null, "name =" + tail.name + "id =" + tail.id);

tail = tail.next;

}

}

Sub deleteFromTail () {}

If only a single node in the list

JOptionPane.showMessageDialog(null,"delete***=1");

/ * If (head == tail)

head = tail = null;

else {}

JOptionPane.showMessageDialog(null,"delete***=2");

StudNode temp.

Temp = head;

While (temp.next! = tail) {}

Temp = temp.next;

JOptionPane.showMessageDialog (null, "led2 inside while" + tail.name + "id =" + tail.id);

}

tail = temp;

tail. Next = null;

JOptionPane.showMessageDialog (null, "delete3 =");

}

*/

}

Public Shared Sub main (String [] args) {}

StudList obj = new StudList ();

obj.create4ElementList ();

obj.display4List ();

JOptionPane.showMessageDialog (null, "deleteOOO1 =");

obj.deleteFromTail ();

JOptionPane.showMessageDialog (null, "deleteFFF4 =");

obj.display4List ();

}

}

Someone please guide me.

Zulfi.

Hello

His work. I can't believe. I just changed the name of the file from StudListDel2.java to StudListDel3.java & changed the name of class, he began to work.

I don't know if the logic is correct. But the logic is correct because I follow the logic of deletion of a book that I used 'while' Loop instead of "for". If any body having time, please read the code of void deleteFromTail () { is correct or not so that I shouldn't be passing wrong information.}

The complete code is:

public class StudListDel3 {}

StudNode1 head, tail, last;

StudListDel3 () {}

last = Chief = tail = null;

}

Sub create4ElementList () {}

Add them to the queue

int id = 1;

int i = 0;

String name = "THIS" + id;

StudNode1 newNode;

newNode = new StudNode1 (id, name);

head = newNode;

last is tail is newNode;

for (i = 0; i<4; ++i)="">

ID ++;

name = "THIS" + id;

newNode = new StudNode1 (id, name);

Last.Next = tail. Next = newNode;

last is tail is newNode;

tail. Next.Next = null;

}

}

Sub display4List () {}

tail = head;

{while(tail!=null)}

JOptionPane.showMessageDialog (null, "name =" + tail.name + "id =" + tail.id);

tail = tail.next;

}

}

Sub deleteFromTail () {}

If only a single node in the list

JOptionPane.showMessageDialog(null,"delete***=1");

If (head is tail)

head = tail = null;

else {}

JOptionPane.showMessageDialog(null,"delete***=2");

StudNode1 temp.

Temp = head;

JOptionPane.showMessageDialog (null, "first and foremost remove * = 3");

While (temp.next! = last) {}

JOptionPane.showMessageDialog (null, "Inside all-in-1");

Temp = temp.next;

JOptionPane.showMessageDialog (null, "inside led2 while name =" + temp.name + "id =" + temp.id);

}

last is tail is temp;

Last.Next = tail. Next = null;

JOptionPane.showMessageDialog (null, "delete3 =");

}

}

Public Shared Sub main (String [] args) {}

StudListDel3 obj = new StudListDel3 ();

obj.create4ElementList ();

obj.display4List ();

JOptionPane.showMessageDialog (null, "deleteOOO1 =");

obj.deleteFromTail ();

JOptionPane.showMessageDialog (null, "deleteFFF4 =");

obj.display4List ();

}

}

Thanks for your reply. Its really beneficial when we see the flow back of great programmers like you. I'm not a programmer.

Zulfi.

Tags: Java

Similar Questions

  • question of ListField remove the last element

    Hi all!

    Is there a known problem in ListField which explains the revival of an OutOfboundException when removing an element from a list with a single element?

    When you use listField.delete () I get this exception when the screen tries to set the focus.

    Thank you for your response. I finally solved the problem in my case using the substitution of "isFocusable" you describe here.

    While the default empty string is not the best solution for me display information when the list does not contain any element, I implemented the my own specific logic with a custom LabelField displayed instead of the ListField.

  • I've added two elements (accessibility and analyze) in the Tools menu of right hand.  How to remove or hide?  Or at least rearrange the elements of the toolbar. I want to Sign &amp; certify be the last element/section.  Thank you.

    I've added two elements (accessibility and analyze) in the Tools menu of right hand.  How to remove or hide?  Or at least rearrange the elements of the toolbar. I want to Sign & certify be the last element/section.  Thank you.

    Hi Stacey Nathan,

    To remove the items from right toolbar, click Tools at the top.

    Then open the fall down to the accessibility or analyze and select 'delete the shortcut '.

    In a similar way, select "Add a shortcut" in the Tools drop-down menu to add to the tool on the right pane.

    Let us know if you need help.

    Kind regards

    Meenakshi

  • Remove the last comma before reading csv files

    Hello

    I'm working on a VI that reads a lot of files csv (created by an application) using the built-in "worksheet File.vi reading" before combining in a report by using the excel report generation tool. 'All lines' are read in the csv file by using the worksheet File.vi reading.

    There are cases of csv files, where there an unwanted comma to the end of the line and an extra cell (with no data) appears in the final report. I was wondering if there is an easy way to remove it (rather than passing through each line and get rid of it).

    Thank you!

    You will need to go through each line, look at the last element and delete it if it is an empty string.  But a loop, it's easy:

    Read the spreadsheet, get 2D array of strings.  For each line, download the last element.  Test if she is a Virgin.  If so, remove it from the table.  If this is not the case, switch the blank table.

  • How to view the last element in a dynamic table 1 d

    Hello..

    I want to display the value of the last element in a dynamic array 1 d... / I mean... If I stop the vi race, I need to display the last element of the array... How can I do this?

    and is it possible to use a button to start the vi... instead of using the Run button on the face before of the vi?

    An array of index!.  Size of table allows to determine the size of your array, subtract 1, that feed into the terminal array of Index index.

    You start the VI running somehow.  It can be assigned to run when opening.  Assuming that what you want is a way to type values in a front panel, press a GO button you created on the front panel, then have the real part of the VI to run.  You can use a structure of the event.  Or put a while loop at the beginning with a small wait next statement which basically just asks the GO button.  When you press this button, the Boolean value true stops the whole loop and allows the program to move on the main body of your program.

  • Stopping everything in a loop after the last element of a 2D array

    How to stop a while loop after the last element of a 2d array.  I tried an uninitialized matrix wiring constant and comparison with table 2d, which has been indexed to a 1 d table, but that did not work.

    Hahaha, Hey, it's true what they say, a picture is worth a thousand words

  • stop all loop after the last element of the array

    I want to stop a while loop after the last element of an array. I can't use table size because the size of the array can change within the program.  What should I do?

    Why not use the function empty array like this...?

  • How can I edit a wav file and remove the last 10 minutes?

    I have a wav file which is an hour of time.  I want to remove the last 10 minutes.  Can I do this with Windows Media Player?  How?  Thank you very much, I am very low tech.

    The freeware "Audacity" should be able to do this:
    Audacity: <> http://audacity.sourceforge.net/ >

    HTH,
    JW

  • WHEN UPDATING WE REMOVE THE LAST?

    I OFTEN IGNORE UPDATE OF WINDOWS, BECAUSE THE FILES ARE QUITE LARGE AND I'M AFRAID THAT WITH ALL THESE UPDATES, THE COMPUTER WILL RUN MEMORY OR SPACE.  WE REMOVE THE UPDATE TO UPDATE A MORE RECENT VERSION?

    STILL CONFUSED

    Monday, March 11, 2013 07:43:15 + 0000, cynthiaO wrote:

    I OFTEN IGNORE UPDATE OF WINDOWS, BECAUSE THE FILES ARE QUITE LARGE AND I'M AFRAID THAT WITH ALL THESE UPDATES, THE COMPUTER WILL RUN MEMORY OR SPACE.  WE REMOVE THE UPDATE TO UPDATE A MORE RECENT VERSION?

    Ouch! Please do not yell at us. We can hear you if you type normally,
    in different cases.

    Number of points:

    1 many updates are essential to your safety, and you play
    with fire if you do not install them. Please do not ignore the.

    2 updates do not use memory (or at least, they use only one very)
    small amount of memory). Disk space is what they use.

    3. even the amount of disk space they use is low and so a update
    requires you to run out of disk space, that you have enough disk space.
    and need to buy a second hard drive or replace what you have with a
    cotyledon. What is your car, and how it is free?

    4. do not remove the last update when you install a newer version. You
    need to keep all installed updates. Thus, for example, if update 1
    protects you from A threat and update 2 protects the threat of B,
    keep the 1 update when you install update 2. If you do not, you will be
    exposed to a threat all over again.

  • EqualLogic - remove the last member of the Group

    I want to remove the last member of a pool.  Data has been moved to the other pools.  Will I need to use the reset directly related to the table command?  It is also the default pool but I understand that I can not remove the default pool and it's ok.

    Hello

    If there are yet other members of the group, then NO, please do not use "reset".   That is only used when it is the only member of the Group overall.   You always use the option 'remove member '.  Either through the user interface or the CLI.

    Any pool can be designated as the "default".

    Kind regards

    Don

  • My printer will not remove the last print job

    My printer will not remove the last print job and does not meet what I already found on internet support

    Hello

    If you haven't done so already, try the following.

    From the desktop, hold down the Windows key and press R.  In the run window, type services.msc and press to enter.  Scroll down to the print spooler service, right click and select Properties, then click the Stop button.  Now search for C:\Windows\System32\Spool\PRINTERS, then delete the work inside this folder - you may need to click a command prompt to get the authority to open the PRINTERS folder.

    Restart the computer and you should find that the document has been deleted.

    Kind regards

    DP - K

  • Remove the last sms progrmatically

    How to remove the last progrmatically of sms? Is it possible to do so.

    There is no access to stored sms messages

  • How can I remove the last action in my story in Lightroom 5

    I want to remove the last action of my story. I know that Ctrl Z is back, but the action is still there

    Hey Vic,

    Please follow the below items for the same.

    Adobe Photoshop Lightroom 4 * cancel the setting of the image

    When to use Reset and history to undo your Lightroom develop work | Lightroom training Laura shoe, tutorials and tips

    Kind regards

    ~ Mohit

  • How to remove the last session of the user of the SQL backend?

    Sometimes the user session gets closed between some of the work for any reason.

    When the next time that the user logs on P6, he gets an error or special functionaly dosen't work for this user or the system hangs.

    In this case if I decided to clear the history of the last session of this user from the databases, how to write the SQL query?

    I don't want to remove all user sessions in the table USESSION and USESSAUD, I just want to remove the last session of the user to particular user (e.g., XYZ).

    You can consult Re: currently connected users

  • Remove the last 35 days of a table data

    Hello

    I had a table to n days of data. I need to remove the last 35 days of data. My table has consecutive dates i.e. There were no load weekend or holidays...

    (1) Using INTERVAL command can simply calculate the difference. So it won't work.

    (2) I can use RANK to find the sequence. Is there a better way to write a logic to delete?.

    concerning

    KVB

    PurveshK,

    I think you have the right idea. Just get the ID of the innermost query.

    This should be quite effective, especially if there is an index on the date.

    drop table t;

    create table t:

    Select trunc (sysdate) - level * 2 double dt connect by level<=>

    delete t

    where rowid in)

    Select rn

    de)

    Select the rowid rn, dense_rank() over (order by dt desc) dr

    t

    )

    where dr<=>

    );

    Post edited by: StewAshton:

    Furthermore, the date field must be NOT NULL for the index be used - or even add WHERE DATE IS NOT NULL to the innermost query.

Maybe you are looking for