Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Error of missing return statement while implementing Array

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error of missing return statement while implementing Array

    hi all.
    this is my first post in here.
    i have problem in return type but can help me ?

    this is my code :
    public ArrayList<Operator> getlist() throws ClassNotFoundException, SQLException{
     
            ArrayList<Operator> operators = null;
            Operator operator= null;
            Command_msg = "SELECT * FROM Operator";
     
                  connection = DBCore.Conn();
                statement = connection.createStatement();
                ResultSet rs = statement.executeQuery(Command_msg);
                operators = new ArrayList<Operator>();
                while(rs.next()){
                    operator = new Operator();
                    operator.setUsername(rs.getString("Username"));
                    operator.setPassword(rs.getString("Password"));
                    operator.setName(rs.getString("Name"));
                    operators.add(operator);
     
            return operators;

    and

     
        //create object From Operator
        private Operator operator;
     
        //create array of Operators
        private Operator[] operators;

    know the error is : missing return Statement


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Problem in Array return type

    Count your curly braces {}. The compiler thinks your return statement is inside the loop. Code indentation is for human eyes, the compiler ignores it.

Similar Threads

  1. Java error "java.lang.StackOverflowError"
    By sanatkumar in forum Exceptions
    Replies: 2
    Last Post: July 7th, 2009, 02:40 PM
  2. [SOLVED] Array loop problem which returns the difference between the value with fixed value
    By uplink600 in forum Loops & Control Statements
    Replies: 5
    Last Post: May 15th, 2009, 04:31 AM
  3. Java program for 2-D Array Maze
    By Peetah05 in forum Collections and Generics
    Replies: 11
    Last Post: May 8th, 2009, 04:30 AM
  4. Type casting error in Java
    By Eric in forum Java Theory & Questions
    Replies: 3
    Last Post: December 13th, 2008, 04:11 PM
  5. Replies: 1
    Last Post: November 22nd, 2008, 01:32 PM