Results 1 to 3 of 3
  1. #1
    dburgess is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default Missing Return Statment, HELP PLEASE.

    i am writing a part of my code which takes a value entered into a text box and applies a method to it when the action listener is clicked, in netbeans i am presented with the Missing Return Value error and am very confused. below i will show code for both the action listener and the method its self

    [CODE] submitsearch.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {

    whatToSearch = searchfield.getText();
    result = SearchString(whatToSearch);




    }
    });

    public String SearchString(String result)
    {
    String input;

    try{
    String details, id, line;
    int count;
    Scanner housenumber = new Scanner(new File("writeto.txt"));
    while(housenumber.hasNext())
    {
    id = housenumber.next();
    line = housenumber.nextLine();
    {

    if(!housenumber.hasNext())
    JOptionPane.showMessageDialog(null,"No Properties with this criteria");
    }

    if(result.equals(id));
    {
    JOptionPane.showMessageDialog(null,id + line );
    }

    }
    }

    catch(IOException e)
    {
    System.out.print("File failure");
    }
    }
    }

    any idea where and what the return statement should be? Thanks in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Can you show us where your IDE thinks there is a problem? Does it refer to a line of code?
    What error do you get when you compile it?
    Java Code:
    public String SearchString(String result)
    This method is defined to return a String object. Where does it do that?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Missing Return statement =[
    By avirunes in forum New To Java
    Replies: 6
    Last Post: 02-12-2011, 10:34 AM
  2. Missing return statement
    By gkoef in forum New To Java
    Replies: 8
    Last Post: 01-01-2011, 02:52 AM
  3. Missing return statement error.
    By Fortu in forum New To Java
    Replies: 2
    Last Post: 12-11-2010, 09:15 PM
  4. Missing a return statment??? (toString)
    By daniellex0x in forum New To Java
    Replies: 9
    Last Post: 10-18-2010, 01:19 AM
  5. missing return statement
    By bayan in forum New To Java
    Replies: 6
    Last Post: 04-26-2010, 03:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •