lab1ans - for (int index = namePosition+1; index...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1. private String getDirectory() { StringBuffer sb = new StringBuffer(); for (int i = 0; i < numEntries; i++) sb.append(directoryArray[i].getName() + " / " + directoryArray[i].getNumber() + "\n"); return sb.toString(); } 2. public String removeEntry(String name) { int namePosition = find(name); if (namePosition != -1) { String oldNumber = directoryArray[namePosition].getNumber();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (int index = namePosition+1; index &lt; numEntries; index++) directoryArray[index-1] = directoryArray[index]; // OR System.arraycopy(directoryArray, namePosition+1, directoryArray, namePosition, numEntries-(namePosition+1)); directoryArray[numEntries-1] = null; numEntries--; modified = true; return oldNumber; } return null; // if name not found }...
View Full Document

Ask a homework question - tutors are online