java - Adding a toString method to a linked list -


i have created linked list class make simple register, can add , remove students list. not sure how create tostring method linked list, best way of going this? in advance!

import java.util.*; public class registry {   linkedlist<student> studentlist         = new linkedlist<student>(); //setting type parameter     public registry() {}   public void addstudent(student astudent) {}   public void deletestudent(int studentid) {}   public string tostring(){}     public string format() {}   } 

linkedlist has tostring() method inherited abstractcollection.

tostring  public string tostring()  returns string representation of collection. string representation consists of list of collection's elements in order returned iterator, enclosed in square brackets ("[]"). adjacent elements separated characters ", " (comma , space). elements converted strings string.valueof(object).  overrides:     tostring in class object  returns:     string representation of collection 

isn't want?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -