Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding and replacing nodes in a Linked List
    primarykey
    data
    text
    <p>I need to be able to find and replace user information in a Linked List. I have been reading several tutorials and examples but it doesn't seem to work. The set method used for linked lists isn't working. So I am wondering if I am implementing it wrong or what. Any help would be great. Also just FYI my linked list is loaded from a file and basically its just user information with each element on a different line.</p> <p>i.e.</p> <pre><code> int index = account.indexOf(hobby); account.set(index, "New String"); </code></pre> <p>Code:</p> <pre><code>private void jButtonP1ActionPerformed(java.awt.event.ActionEvent evt) { LinkedList&lt;Account&gt; account = new LinkedList&lt;Account&gt;(); //user information String username = jTextFieldP3.getText(); String password = jPasswordFieldP1.getText(); String email = jTextFieldP4.getText(); String name = jTextFieldP1.getText(); String breed = (String) jComboBoxP4.getSelectedItem(); String gender = (String) jComboBoxP3.getSelectedItem(); String age = (String) jComboBoxP1.getSelectedItem(); String state = (String) jComboBoxP2.getSelectedItem(); String hobby = jTextFieldP2.getText(); //combo boxes String passchange = (String) jComboBoxP13.getSelectedItem(); String emailchange = (String) jComboBoxP14.getSelectedItem(); String namechange = (String) jComboBoxP6.getSelectedItem(); String breedchange = (String) jComboBoxP7.getSelectedItem(); String genderchange = (String) jComboBoxP8.getSelectedItem(); String agechange = (String) jComboBoxP9.getSelectedItem(); String statechange = (String) jComboBoxP10.getSelectedItem(); String hobbychange = (String) jComboBoxP11.getSelectedItem(); String accountcancel = (String) jComboBoxP5.getSelectedItem(); Account a = new Account(username, password, email, name, breed, gender, age, state, hobby); account.add(a); if(username.equals("") || password.equals("") || email.equals("")) // If password and username is empty &gt; Do this &gt;&gt;&gt; { jButtonP1.setEnabled(false); jTextFieldP3.setText(""); jPasswordFieldP1.setText(""); jTextFieldP4.setText(""); jButtonP1.setEnabled(true); this.setVisible(true); } else if(a.onList(username) || a.onList(password) || a.onList(email)) { int index = account.indexOf(hobby); account.set(index, "New String"); } else { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload