So I've made a bit of the directory and I want to make a tester that tests the methods that I've declared. The code for the directory is shown below.

package TelephoneDirectory;
public class TelephoneDirectory { 
    String name; 
    String telnumber; 

    * @param name a person's name 
    * @param telno a person's telephone number 
    public TelephoneDirectory(String name, String telno){ = name; 
        this.telnumber = telno; 

    public String getName(){ 
        return name; 

    public String getNumber(){ 
        return telnumber; 

    public void setNumber(String telno){ 
        telnumber = telno; 

    public String toString(){ 
        return name + "\t"+telnumber; 

    public String format(){ 
        return "Name: " + name + "\tTelephone: "+telnumber; 

And so far with the tester, I have as shown below:

package TelephoneDirectory;
 * @author matt
public class DirectoryTester {
    public static void main(String[] args)
        System.out.println(" ");

I'm really stuck on this and any help would be great :)

You need to create some new instances of TelephoneDirectory, then use them to call all the methods and print the results to see if they are correct.
ps: TelephoneDirectory is a very bad name for this class. Instances of the class represent single entries in some directory. A class called TelephoneDirectory should have instances thet represent telephone directories, eg

class TelephoneDirectory {
    private List<DirectoryEntry> theDirectory;
    public void addEntry(DirectoryEntry e) ...
    public DirectoryEntry findByName(String name) ...
    etc etc

    (where DirectoryEntry is the class you called TelephoneDirectory)

if you don't know how to instantiate objects, don't go writing your own classes. learn the basics first.

asJamesCherril pointed out with the 'inline code' tag: use the new keyword.

I am making the same project for my uni course would really appreciate some help as I am struggling with the same thing..

Kalys: don't just hijack a thread, or copy paste someone's code.
that's called plagiarism, and, depending on the rules followed by your university, might get you expelled.

and a diploma from any school that doesn't expel people who cheat like that isn't worth the paper it's printed on.

Hello Kalys3.

As you can see, your vague request for "help" can be seen as an attempt to cheat. Maybe that's not what you intended, but there's no way for anyone to tell from the info you have given.

If you have some genuine questions then start a new thread of your own, explain what you have done so far, and explain what help you need to move on. Someone will help.